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.adFailIfNotExi sts,
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 (http://www.codeproject.com/csharp/csmanagedeventsinkshooks.asp), he is Dexterity, SQL, VB/C#.Net, Crystal Reports and Microsoft CRM SDK developer.
Mercedes Benz s500 rentals Salem ..Formatting and reinstalling windows 98 is very easy if you... Read More
If you copy something from a Web site or elsewhere...... Read More
The first thing that you will notice about Linux Red... Read More
A UNIX Shell is in simplest terms, a command line... Read More
Whether you are an experienced web programmer or a complete... Read More
2005 ? Back to the Future.What does the future hold?... Read More
Healthcare facilities such as clinics, hospitals, and biomedical laboratories can... Read More
Adobe Photoshop is one of the world's leading graphics editing... Read More
A LOT OF UNWANTED FILES.When you uninstall an item of... Read More
Shareware has been fighting the stigma of being misunderstood for... Read More
When you double-click a layer in the Layer Palette, you... Read More
Introduction To ISDN, Part III: Configuring PPP PAP AuthenticationNow we... Read More
Microsoft Business Solutions Great Plains version 8.5, 8.0, 7.5, Great... Read More
Spyware is like the new technological nuclear weapon on the... Read More
I started using PIP (Picture It Publishing) Platinum 2002 right... Read More
The java programming language is becoming more and more popular... Read More
Microsoft Great Plains is main mid-market application from Microsoft Business... Read More
Well, even if the combination might look very unusual, we... Read More
Several software companies design programs for preventive maintenance. Most of... Read More
Viruses and spyware usually show up on your computer one... Read More
Microsoft released Service Pack 2 (SP2) for the Windows XP... Read More
Just stress testing one of the latest Linux distributions. Been... Read More
This article is the third of a series of articles... Read More
Microsoft CRM has built-in conversion tool, however you should probably... Read More
IntroductionSurprised, by the title? well, this is a tour of... Read More
Dowagiac cheap limo service ..In the new era of internet marketing the problem of... Read More
Google Inc. has launched a new software package that allows... Read More
Although statistics often is blamed for various deadly sins --... Read More
Microsoft Great Plains has full-featured Manufacturing suite of modules: Capacity... Read More
When Windows fails to boot it is normally caused by... Read More
Research bears that less than 70 percent of development projects... Read More
I have recently created my first Php program. I wanted... Read More
Microsoft CRM has built-in conversion tool, however you should probably... Read More
If you look back to the history, you will see... Read More
Microsoft Business Solutions CRM proved to be reliable solution in... Read More
In 2004 Oracle, Inc. made its new step toward J2EE... Read More
Microsoft Business Solutions Great Plains and MS CRM (client relation... Read More
Looks like Microsoft Great Plains becomes more and more... Read More
Most people don't use Photoshop to its fullest capabilities. Here... Read More
If you would like to pick something from Microsoft, or... Read More
Just when you thought you were Web savvy, one more... Read More
Microsoft Business Solutions Great Plains is very good fit for... Read More
What is 'adware'?Adware is basically software or scripts that are... Read More
For a windows user like me, just can watch with... Read More
Adware is a type of Spyware program that displays some... Read More
Microsoft Great Plains has substantial mid-market share in the USA... Read More
When Great Plains Software introduced the first graphical accounting application... Read More
Microsoft Business Solutions CRM is present several years on the... Read More
Microsoft Great Plains is becoming more and more popular and... Read More
Icons are used everywhere; right from software applications, to internet... Read More
Software |