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.
scheduled maid service Northbrook ..Spyware and Adware infest over 90 percent of computers in... Read More
The intuitive algorithm.Roger Penrose considered it impossible. Thinking could never... Read More
Are Spreadsheets Robbing your Enterprise of Competitive Advantage?'90% of "average"... Read More
IBM Lotus Notes Domino and Microsoft CRM (Client Relation Management)... Read More
Does Microsoft Have any Real Competition? Copyright (c) 2003 Gregory... Read More
In the Clinton era the status quo was simple: you... Read More
Executive SummaryAn effective plan for entering, cleaning and updating the... Read More
If you look back to the history, you will see... Read More
Microsoft Business Solutions Great Plains is mid and even corporate... Read More
Trying to figure out a stream in banning one email... Read More
This article is the first of a series of articles... Read More
IBM Lotus Domino or Microsoft Exchange?The severe competition continues for... Read More
Creating a new markup language.Introduction.General Reuse Markup Langauge, or GRML,... Read More
MS CRM is very close to document workflow automation, including... Read More
Shareware is software that you can try before you buy;... Read More
So, you've bought a new Macintosh, and now you may... Read More
Although we don't know whether Microsoft ever envisioned such a... Read More
In part III of this ISDN primer, we learned that... Read More
Microsoft SQL Server is the leader for inexpensive and middle... Read More
Microsoft Great Plains is main Microsoft Business Solutions accounting package... Read More
Several software companies design programs for preventive maintenance. Most of... Read More
Make-or-Break Factors in Success and ProfitabilityFor quick printers, estimating can... Read More
If you have Great Plains Dynamics/eEnterprise (version 6.0 or earlier)... Read More
During the years of our consulting practice, which comes back... Read More
Microsoft Business Solutions Great Plains serves multiple industries in the... Read More
reliable maid service Highland Park ..Heard about the Quark "killer"?Adobe InDesign CS2. Will it really... Read More
Great Plains Software Dynamics, Dynamics C/S+, eEnterprise were written on... Read More
Let's say that you have a software project that's under... Read More
Which Type of Shop Can Rely On A Home Built... Read More
If you have been using the Internet for any amount... Read More
Great Plains Inventory Management (IV) module gives your business a... Read More
Microsoft Great Plains - Microsoft Business Solutions accounting and ERP... Read More
Great Plains Fixed Assets Management module is a robust tool... Read More
TCO (Total Cost Ownership) is the buzzword in... Read More
Microsoft Business Solutions Great Plains has several options to enable... Read More
Microsoft Great Plains is now standard mid-market ERP application, serving... Read More
I completed an experiment recently. I wanted to find out... Read More
Should one use Windows Update?This topic has good and valid... Read More
How to delete the user? This is the first problem... Read More
1. With mapping software you can create a report that... Read More
In this article you will find some background information about... Read More
If you feel intimidated when someone tries to teach you... Read More
Microsoft CRM ? Client Relationship Management package from Microsoft Business... Read More
Microsoft CRM is CRM answer from Microsoft and attempt to... Read More
Our company, Novaprof Inc., developed unique software - DB Integration.... Read More
We are in a transition phase in the Managerial Administration... Read More
New post-recession era has new features, which didn't exist in... Read More
GroupwareEfforts are continually made to manage the unavoidable ad hoc... Read More
Microsoft CRM is now on the scene and it is... Read More
Music downloads are off the charts! We're listening to digital... Read More
Software |