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 Lake Forest ..Domino server is a buffer between the operation system and... Read More
Scrapbooks are very popular these days. I think that almost... Read More
Shareware has been fighting the stigma of being misunderstood for... Read More
Do you remember that frustrating feeling when you find an... Read More
Microsoft Great Plains and Microsoft CRM become more and more... Read More
The most important things you can do for your computer... Read More
A wiki is an editable text-based website. But you don't... Read More
If you are in a business that passes documents around... Read More
Microsoft Business Solutions CRM proved to be reliable solution in... Read More
The various resume software offered, particularly on the internet, can... Read More
Stop the Runaway MouseWhat's the "runaway mouse?" You've seen it...you... Read More
NOTE: Please take time to read on - it may... Read More
Microsoft Business Solutions Great Plains is very popular ERP/MRP applications... Read More
Great Plains Integration Manager scripting and translation - overview for... Read More
The adware and spyware definitions list is very long. But... Read More
Microsoft Business Solutions is now in process of creating so... Read More
Microsoft Business Solutions Great Plains was historically designed to serve... Read More
Anyone who has ever used Microsoft Word knows that it... Read More
Microsoft CRM is now on the scene and it is... Read More
There are so many different programs that clutter up your... Read More
Should one use Windows Update?This topic has good and valid... Read More
Great Plains Fixed Assets Management module is a robust tool... Read More
When you visit department stores and see that majority of... Read More
In our small article we'll consider Microsoft Business Solutions Great... Read More
Combining Microsoft Business Solutions Great Plains ERP with non-Microsoft Business... Read More
scheduled maid service Winnetka ..Former Great Plains Software Dynamics/eEnterprise, and currently Microsoft Business Solutions... Read More
Microsoft has never released a service pack for Windows98 SE,... Read More
The adware and spyware definitions list is very long. But... Read More
At the end of XX century, in the late 1990th... Read More
Looks like Microsoft Great Plains becomes more and more... Read More
So let's begin crunching down these 300 images using Adobe... Read More
Microsoft Business Solutions Great Plains is very good fit for... Read More
If there still are few unprotected computers left, I haven't... Read More
You turn on your computer, and it doesn't look quite... Read More
In the early days of the personal computer, we're talking... Read More
As you probably know, when Microsoft purchased Great Plains Software... Read More
Whether you are a small consultancy firm, a medium sized... Read More
How would you like to prevent spyware and adware from... Read More
Three highly respected names in Human Resources have joined forces... Read More
Microsoft Business Solutions ? Navision is an integrated solution for... Read More
How many steps does it take you to locate and... Read More
Microsoft CRM is now on the scene and it is... Read More
While I was in college, if you would have asked... Read More
Have you ever noticed that when you look at your... Read More
Table of Contents1) Introduction 2) Related Work 3) Framework 4)... Read More
Microsoft Business Solutions Great Plains has substantial market share among... Read More
If you have Microsoft Great Plains and support it for... Read More
As Mozilla Firefox nears 10% market share, with well over... Read More
IBM Lotus Notes Domino and Microsoft CRM (Client Relation Management)... Read More
While I was preparing some personal background information for a... Read More
Software |