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.
tidy up service Glenview ..There are two approaches for application integration:? Programmer's approach ?... Read More
If you have been running Windows XP for a couple... Read More
Sometimes your PC will start acting strange for no apparent... Read More
Around the same time Microsoft made its move with .Net... Read More
Microsoft CRM is CRM answer from Microsoft Business Solutions. If... Read More
In a previous article, I wrote about OpenOffice... Read More
Microsoft Business Solutions Great Plains has many years of successful... Read More
The fact that a software tester is a most infamous... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
Trying to figure out a stream in banning one email... Read More
Formatting and reinstalling windows 98 is very easy if you... Read More
What is Interactive Mapping?Interactive mapping is a visual display medium... Read More
Lotus Domino/Notes ? Microsoft Great Plains tandem as ERP with... Read More
Microsoft Business Solutions Great Plains serves multiple industries in the... Read More
This article illustrates the best practices to improve the performance... Read More
Internet worms. Is your PC infected?If your computer has become... Read More
Whether you are a small consultancy firm, a medium sized... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
Program Flow is what you think it is. How the... Read More
IntroductionPHP can be used for a lot of different things,... Read More
SyncUp, a file synchronizer is designed to assist the home... Read More
For those who still don't know, Microsoft Publisher helps computer... Read More
Great Plains Fixed Assets Management module is a robust tool... Read More
An integral part of any quality CRM system is lead... Read More
Microsoft Business Solutions Great Plains has Project Accounting module where... Read More
full-service cleaning Mundelein ..It would be easy to think, like most people apparently... Read More
Intro This concise article will tell you in plain English... Read More
Microsoft Great Plains is now targeting large and midsize businesses... Read More
This is intermediate level SQL scripting article for DB Administrator,... Read More
Microsoft Great Plains ? ERM from Microsoft Business Solutions and... Read More
Microsoft CRM is CRM answer from Microsoft Business Solutions.The whole... Read More
Do you want to get quality software at a reasonable... Read More
After almost two decades of existence, Quark has become the... Read More
Microsoft Business Solutions Great Plains and MS CRM (client relation... Read More
Anyone who has ever used Microsoft Word knows that it... Read More
The world of small business accounting software can be a... Read More
Microsoft CRM has built-in conversion tool, however you should probably... Read More
Microsoft Business Solutions Great Plains is written in Great Plains... Read More
XML Server can be a Web Server that stores the... Read More
Whether you need to close a sale, gather end-user feedback,... Read More
COMMAND LINE FUNCTIONA powerful command line script processor has been... Read More
I provide, here clear explanations and a count of function... Read More
While I was in college, if you would have asked... Read More
When my daughter was getting into AOL instant messaging (AIM)... Read More
Microsoft Business Solutions Great Plains was historically designed to serve... Read More
For a windows user like me, just can watch with... Read More
Microsoft CRM is CRM answer from Microsoft and attempt to... Read More
As seeing large number of implementations ? in our case... Read More
At the end of XX century, in the late 1990th... Read More
If you look back to the history, you will see... Read More
Software |