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.
cleaning help near Mundelein ..There is many things more frustrating than surfing a website... Read More
Microsoft Business Solutions Great Plains has substantial market share among... Read More
Whether you need to close a sale, gather end-user feedback,... Read More
Midsize business or non-profit organization should decide if one-vendor solution... Read More
Microsoft Great Plains, Navision, Solomon and Axapta are Microsoft Business... Read More
Microsoft CRM is CRM answer from Microsoft Business Solutions. If... Read More
Microsoft Great Plains might be considered as ERP platform to... Read More
The world of small business accounting software can be a... Read More
Fleet Maintenance Management is a critical position in any company... Read More
If you have Microsoft Great Plains and support it for... Read More
Before September of 1995, Microsoft ignored the Internet because their... Read More
One of the things we can be as certain of... Read More
Microsoft Business Solutions Great Plains is mid and even corporate... Read More
Document Management or Enterprise Information Management is perhaps one of... Read More
We all already got used to computer monitoring both at... Read More
Microsoft CRM is winning market share step-by-step from such the... Read More
I have recently created my first Php program. I wanted... Read More
Here is some free software tools to help you build... Read More
Shareware is software that you can try before you buy;... Read More
Icons are used everywhere; right from software applications, to internet... Read More
Background: For many organizations like ours, the interim target of... Read More
Healthcare facilities such as clinics, hospitals, and biomedical laboratories can... Read More
Microsoft CRM is new player on the CRM software... Read More
Combining Microsoft Business Solutions Great Plains ERP with non-Microsoft Business... Read More
We've all seen the ads on TV for Netzero 3G.... Read More
reliable maid service Wilmette ..Microsoft Business Solutions Great Plains, Solomon, Navision, Axapta, Microsoft CRM... Read More
Not all of us have the luxury of working both... Read More
Siebel is traditional CRM market leader, however and mostly due... Read More
Microsoft CRM is now on the scene and it is... Read More
Today's business world is fast-paced. No matter what it is... Read More
Does Microsoft care for WebmastersIt's always been a problem with... Read More
Many reasons made GBM a unanimous choice for experts, one... Read More
In the new era of internet marketing the problem of... Read More
C++ Function templates are those functions which can handle different... Read More
Software Engineering is the Systematic Approach for analysis design implementation... Read More
Shareware is software that you can try before you buy;... Read More
Great Plains Inventory Management (IV) module gives your business a... Read More
Microsoft Great Plains could be tuned and setup to fit... Read More
Is Photoshop CS2 worth the upgrade? You bet it is!... Read More
Assertion facility is added in J2SE 1.4. In order to... Read More
This article is for advanced Microsoft CRM SDK C# developers.... Read More
To all web designers out there, this article is for... Read More
Just when you thought you were Web savvy, one more... Read More
Microsoft Great Plains, Navision, Solomon and Axapta are Microsoft Business... Read More
The most important benefit of XML is its simplicity. Though... Read More
This article is the first of a series of articles... Read More
Anyone who has ever used Microsoft Word knows that it... Read More
Microsoft Great Plains serves majority of US based horizontal and... Read More
MSN messenger is a pretty cool invention. I mean I'm... Read More
Sales are all about leverage, because there is only so... Read More
Software |