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.
custom home cleaning Wilmette ..Spyware is software or hardware installed on a computer without... Read More
Stop the Runaway MouseWhat's the "runaway mouse?" You've seen it...you... Read More
Here is some free software tools to help you build... Read More
Before being able to choose a secure Internet communication system,... Read More
Microsoft Great Plains as ERP and Microsoft CRM as... Read More
The major reason I recommend getting your hands on real... Read More
Since technology changes so quickly, it is hard to begin... Read More
The research in the field of Natural Language Processing usually... Read More
If you've been using MySQL database to store your important... Read More
Words we choose to describe things and phenomena often show... Read More
COMMAND LINE FUNCTIONA powerful command line script processor has been... Read More
The most important benefit of XML is its simplicity. Though... Read More
Document Management or Enterprise Information Management is perhaps one of... Read More
The objective for Zandi Digital is to make available clever... Read More
NOTE: Please take time to read on - it may... Read More
It would be easy to think, like most people apparently... Read More
With this small article we are continuing Microsoft Business Solutions... Read More
As you probably know, when Microsoft purchased Great Plains Software... Read More
Assertion facility is added in J2SE 1.4. In order to... Read More
Shareware has been fighting the stigma of being misunderstood for... Read More
Microsoft Client Relation Management system (Microsoft CRM) and Microsoft RMS... Read More
In this short FAQ style article we would like to... Read More
Great Plains Fixed Assets Management module is a robust tool... Read More
Icons are used everywhere; right from software applications, to internet... Read More
When my daughter was getting into AOL instant messaging (AIM)... Read More
same day cleaning service Morton Grove ..Anyone who has ever used Microsoft Word knows that it... Read More
Imagine something that follows you home and sets itself up... Read More
For those who still don't know, Microsoft Publisher helps computer... Read More
Spyware and Adware infest over 90 percent of computers in... Read More
While Adobe is the most known maker of PDF tools,... Read More
Once a business idea is selected, it is highly recommended... Read More
It???s easy to understand why you might be drawn to... Read More
Microsoft Business Solutions Great Plains, former Great Plains Software Dynamics... Read More
Microsoft Great Plains is main Microsoft Business Solutions accounting package... Read More
Microsoft bought Navision, Denmark based software development company, along with... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
We'll give you non formal view, based on our consulting... 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
As of now - Great Plains Dynamics/eEnterprise is transformed/renamed into... Read More
There is many things more frustrating than surfing a website... Read More
The objective for Zandi Digital is to make available clever... Read More
If you use Microsoft Outlook (or similar applications) for e-mailing,... Read More
Microsoft CRM is CRM answer from Microsoft and attempt to... Read More
Microsoft Great Plains could be tuned and setup to fit... Read More
The world of small business accounting software can be a... Read More
A few months back I really got sick of my... Read More
And kill the best layout software in the process of... Read More
Former Great Plains Software Dynamics/eEnterprise and currently Microsoft Business Solutions... Read More
Almost all new and major brand of PCs come with... Read More
Software |