Removing Incoming Email In Ms Exchange, C# Example
|
The purpose of one of our projects was MS Exchange handler for processing incoming email.
The basic source of knowledge was this article "Developing Managed Event Sinks/Hooks for Exchange Server Store using C#" by Logu Krishnan, published to the address http://www.codeproject.com/csharp/CsManagedEventSinksHooks.asp, and also examples from Microsoft Exchange SDK.
We utilized Synchronous Events and created the handler, which fires on OnSyncSave event. The handler creates activity record in Microsoft CRM and then removes the message in the Exchange database before the commitment:
public void OnSyncSave(IExStoreEventInfo pEventInfo, string bstrURLItem, int IFlags) {try {if (IFlags ((int)EVT_SINK_FLAGS.EVT_SYNC_COMMITTED + (int)EVT_SINK_FLAGS.EVT_IS_DELIVERED)) {
ProcessMessage(pEventInfo, bstrURLItem, IFlags);
}
}
catch (Exception ex) {
log.Debug(ex.Message + "" + ex.StackTrace);
}
finally {
LogManager.Shutdown();
}}
For Exchange handlers debugging - it is the extremely convenient to use system log4net in RollingLogFileAppender or RemoteAppender modes (for multiple instance of COM + objects). You can read more on this subject here http://logging.apache.org/log4net/To allow the handler incoming mail removal, it is necessary to give proper rights to the user, under which account the COM+ application runs the handler. These are rights on change of the information in user's boxes for whom it is registered (Windows 2003 Server: Active Directory Users and Computer -> Users -> Properties (for COM+ application account) -> Exchange Advanced -> Mailbox Rights). And now the code:
private void DeleteMessage(string bstrURLItem) {try {
ADODB.Connection oCn = new ADODB.Connection();
oCn.Provider = "exoledb.datasource";
oCn.Open(bstrURLItem, "", "", -1);
if(oCn.State 1) {
log.Debug("Good Connection");
}
else {
log.Debug("Bad Connection");
}
ADODB.Record rec = new ADODB.Record();
rec.Open(bstrURLItem, oCn,
ADODB.ConnectModeEnum.adModeReadWrite,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource,
"", "");
rec.DeleteRecord(bstrURLItem, false);
rec.Close();
oCn.Close();
rec = null;
oCn = null;
}
catch (Exception ex) {
log.Debug(ex.Message + "" + ex.StackTrace);
}}
Happy customizing!Boris Makushkin
Boris Makushkin is Software Engineer in Alba Spectrum Technologies ? USA nationwide Microsoft CRM, Microsoft Great Plains customization company, based in Chicago, Boston, San Francisco, San Diego, Los Angeles, Houston, Atlanta, New York, and Miami and having locations in multiple states and internationally (www.albaspectrum.com), he is Dexterity, SQL, VB/C#.Net, Crystal Reports and Microsoft CRM SDK developer.
|
|
|
Razzle Dazzle Them
Once upon a time not so long ago, there was a little boy who went to the market to try to sell his wares. He wasn't having any luck. "Who will buy my sweet red roses? Two blooms for a penny," he sang ou...(related: Software)
20 Extra Hours Per Week: What Would You Do?
While I was in college, if you would have asked me what I would do if I had an extra 20 hours to spend in a week, the first thing I would have told you is that I would definitely NOT spend it studying. I actually would have gone down a long list of hobbies and activities I would like to do if I had the time. So when my co-workers asked me to find out what owners/managers of sign companies would do if they had an extra 20 hours per week, I was very interested in hearing the responses. What types of activities are sign shop owners doing with their spare time? Was there a common activity or hobby in the sign & graphics industry? Or would I hear several different responses?The ResultsThe results were unexpected to s...(related: Software)
Microsoft Great Plains Ecommerce: Overview For Developer
Microsoft Business Solutions Great Plains was designed back in the earlier 1990th as first graphical ERP/accounting system for mid-size businesses. The architects of Great Plains Dexterity ? this is the internal mid-shell, all Great Plains was written on, designed it to be easily transferable between graphical operating systems (MAC, Windows, Solaris ? potentially) and database platforms ? initially Great Plains was available on Ctree (both Mac and PC) and Btrieve, a bit later high end version Dynamics C/S+ was available on Microsoft SQL Server 6.5. But the idea was to catch or switch winning/losing database platform ? nobody could predict if MS SQL Server, Oracle or DB 2 become a dominant DB platform, like Windows among OS. All these trade-ins for being potential...(related: Software)
Cosmic: A Small Improvement On The Symons Method
The COSMIC FP (function point) software quality metric, is no longer 'proposed' but an actual system in use and internationally recognised, whereas MarkII, like other older systems, is not recognised anywhere, and, even in the UK is in decline if not actually dormant, so this debate is already over.Historically, from my limited understanding of the situation, it seems that originally there were upwards of 35 variants of function point style metrics until the ISO developed criteria for a acceptable solution, ISO 14143: Parts 1 to 5 (1995-2002):The COSMIC group reviewed existing functional size measurement methods, namely the work done in the late 80's by Charles Symons in the UK. The aim was to improve on Albrecht's size index (IFPUG FPA)As stated in many sources, the most important feature...(related: Software)
Running A Program On A Remote Server Using Ssh
How do you run a program on a remote server using ssh?For this example we'll have two servers, one named Johnny and another named Cash. Both are running openssh. Our goal is to have a program on Johnny login to Cash and run a program on Cash. To make the task a little more complex we'll be using different users on each machine.The first thing we'll need to do is generate public and private keys on Johnny. So, logged into Johnny as user 'boy' we create public and private keys by creating them in the .ssh directory as follows:Johnny$> pwd/home/boy/.sshJohnny$> ssh-keygen -t rsa -f sueGenerating public/private rsa key pair.Enter passphrase (empty for no passphrase):...(related: Software)
C++ Tutorial 1, Introduction To C++
Introduction to C++Why Learn C++?C++ may at first seem like a boring, confusing programming language that you can only program command prompt applications with. Well, that is what it is like in the [b]begining[/b]. And you are going to need to l...(related: Software)
A Simple Computer Software Definition
What is Software?Software is a set of instruction written to interface between man and machine.Who writes this instructions?Programmers writes this instructions.How the programmers write the instructions /software?They use computer...(related: Software)
Software Development In 2005 - Back To The Future
2005 ? Back to the Future.What does the future hold? A big question and initially the answer is anything and everything. The predictions are sometimes close but most of the time they are far from the reality. Technology has moves on apace and the core players in the various sectors of the computing industry invest in research and development which increases the rate of technology introduction with performance improvements or benefits outweighing the previous technology that customers/users/consumers must take advantage of, or so that is what they tell us. What is the truth? And what is the future?For the developer community I believe that things have not changed all that much other than there a more defined lines to be drawn between types of developers i.e. games vs corporate applications, mobile vs military. T...(related: Software)
Recovering Microsoft Great Plains Customization ? Tips For It Director
Remember nice and prosperous Clinton era? When you implemented innovative those old days accounting application ? Great Plains Dynamics. And did a lot of customizations to fit your business requirements precisely. You still remember the names of consultants and programmers who did the job and probably the name of the company ? Great Plains reseller in your business metro. This compan...(related: Software)
Do You Know These Facts About Spyware ?
Imagine something that follows you home and sets itself upin your house. It eats your food, enjoys your drinks, readseverything you bring home or purchase. It runs up yourphone bills and no matter where you go, it can follow youand takes notes on everything you do.Generically labeled spyware, your stealth visitor is aprogram or set of programs designed to track your Internetactivity. And, while it hasn't gone as far as above,...(related: Software)
Crystal Reports For Microsoft Great Plains ? Overview For Developer
Microsoft Great Plains is main accounting / ERP application from Microsoft Business Solutions, targeted to the US market. It serves the whole of vertical and horizontal market: most of the industries and company sizes. Crystal Reports on the other hand is the leader in the reporting software industry and Microsoft is willing to use Crystal as main reporting tool for Great Plains, Solomon, Microsoft CRM, .Net platform, etc.
If you are developer who is...(related: Software)
What Is Shareware?
Shareware is software that you can try before you buy; shareware is a kind of marketing method for software. Software developers post trial versions of their software on websites. Consumers can then download the trial version to their computer and evaluate it. If the consumer likes the software they can purchase it. Shareware is also called try before you buy.Today almost every big software compan...(related: Software)
Microsoft Great Plains: Annual Enhancement Program ? How To Be Re-enrolled
Microsoft Business Solutions Great Plains is mid and even corporate market ERP and as being relatively complex and difficult to do self-support in-house, Microsoft Business Solutions requires you first to have so-called VAR of record, or your M...(related: Software)
site-map - Copyright © 2008 | Contact Webmaster | All Rights Reserved. | Software