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.
shuttle to Midway Beardstown .. Lockport Chicago limo O’HareWe all take the computer for granted. I mean, all... Read More
1. Replace Dexterity cursor with SQL Stored Procedure Dexterity... Read More
For a windows user like me, just can watch with... Read More
Fortunately one of the most common reasons cited for the... Read More
Just when you thought you were Web savvy, one more... Read More
The first topic we are going to discuss... Read More
A LOT OF UNWANTED FILES.When you uninstall an item of... Read More
A few months back I really got sick of my... Read More
User interfaces and accessibility are some of the most important... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
There are certain pluses and minuses in both cases and... Read More
Several software companies design programs for preventive maintenance. Most of... Read More
If there still are few unprotected computers left, I haven't... Read More
Microsoft Business Solutions Great Plains is written in Great Plains... Read More
What is IRC?IRC is Internet Relay Chat. It is a... Read More
The Internet is reshaping every form of communications medium, and... Read More
Introduction: The creating of a computer program involves a number... Read More
The US House of Representatives has recently passed the "Spy... Read More
We are in a transition phase in the Managerial Administration... Read More
Microsoft CRM ? Client Relationship Management package from Microsoft Business... Read More
Programming Help for BeginnersWe write programs to instruct computers. When... Read More
Sometimes your PC will start acting strange for no apparent... Read More
(1) Avoid using the same variable again and again for... Read More
Although we don't know whether Microsoft ever envisioned such a... Read More
Microsoft Great Plains - Microsoft Business Solutions accounting and ERP... Read More
Green Bay Hummer H2 SUV rentals ..Microsoft Great Plains serves majority of US based horizontal and... Read More
If you're online using a dialup Internet connection, you'll probably... Read More
In our small article we'll consider Microsoft Business Solutions Great... Read More
How to delete the user? This is the first problem... Read More
Great Plains Accounting, accounting package for mid-size and small companies... Read More
A few months back I really got sick of my... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
What is Interactive Mapping?Interactive mapping is a visual display medium... Read More
Many Webmasters have never bothered to view their website's server... Read More
This is a short article, written in question/answer/FAQ style to... Read More
When it comes to screenplay software each screenwriter needs to... Read More
Microsoft CRM ? Client Relationship Management package from Microsoft Business... Read More
Have you noticed WordPerfect is gearing up for a comeback... Read More
Think of this, first we had the HAM Radio, then... Read More
I provide, here clear explanations and a count of function... Read More
This article is the fourth of a series of articles... Read More
NOTE: Please take time to read on - it may... Read More
So, why should you use any O/R mapping tool? I... Read More
Let's first look at your ERP system selection (without Retail... Read More
Microsoft Business Solutions Great Plains, Navision, Axapta, Solomon and CRM... Read More
The software giants don't do everything and don't always produce... Read More
Hey Guys! Don't raise your eyebrows or fear by hearing... Read More
A UNIX Shell is in simplest terms, a command line... Read More
IBM Lotus Notes Domino and Microsoft CRM (Client Relation Management)... Read More
Microsoft Business Solutions Great Plains serves to the wide spectrum... Read More
Software |