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.
eco-friendly cleaning service Northbrook ...Microsoft Business Solutions Great Plains serves to the wide spectrum... Read More
Every organization which creates collaborative documents, whether they are budgets,... Read More
Need help making sense of algebra? Have algebra lectures in... Read More
Microsoft Business Solutions Great Plains was purchased from Great Plains... Read More
At the end of XX century, in the late 1990th... Read More
If you use Microsoft Outlook (or similar applications) for e-mailing,... Read More
Former Great Plains Software Dynamics/eEnterprise and currently Microsoft Business Solutions... Read More
Microsoft Business Solutions ? Great Plains has captured the US... Read More
Bill of Lading is required report for Logistics and Freight... Read More
Microsoft Great Plains fits to majority of horizontals and retail... Read More
Having from five to ten and more favorite screensavers is... Read More
Executive SummaryAn effective plan for entering, cleaning and updating the... Read More
Do you remember that frustrating feeling when you find an... Read More
How to delete the user? This is the first problem... Read More
Professional services firm cuts costs and improves productivity with integrated... Read More
In the previous ISDN article, we looked at how and... Read More
This is the tutorial where we really get into programming.... Read More
It would be easy to think, like most people apparently... Read More
There are two approaches for application integration:? Programmer's approach ?... Read More
When you need a phone number, you do a quick... Read More
SOFTWARE PIRACY We regularly hear reports... Read More
DBxtra goes ASPGetting to the information hidden within corporate databases... Read More
Background: For many organizations like ours, the interim target of... Read More
Microsoft Great Plains might be considered as ERP platform to... Read More
Former Great Plains Software Dynamics/eEnterprise, and currently Microsoft Business Solutions... Read More
experienced cleaning professionals Deerfield ...The world of small business accounting software can be a... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
Manufacturing in the USA is far away down from mid... Read More
If you would like to pick something from Microsoft, or... Read More
What is Software?Software is a set of instruction written to... Read More
Several software companies design programs for preventive maintenance. Most of... Read More
XML parser is a software module to read documents and... Read More
After almost two decades of existence, Quark has become the... Read More
Microsoft Great Plains is main Microsoft Business Solutions accounting package... Read More
Microsoft Business Solutions Great Plains, former Great Plains Software Dynamics/eEnterprise... 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 provide, here clear explanations and a count of function... Read More
There are two major WYSIWYG(What You See Is What You... Read More
Microsoft SQL Server is the leader for inexpensive and middle... Read More
This article is the fourth of a series of articles... Read More
You have gotten those E_Mails buy software at deep discounts.... Read More
Microsoft Business Solutions CRM is web-based CRM application, deploying all... Read More
I have recently created my first Php program. I wanted... Read More
Programming Help for BeginnersWe write programs to instruct computers. When... Read More
I love new technology. I am still ready to wait... Read More
Microsoft Business Solutions Great Plains was purchased from Great Plains... Read More
In the case when you represent mid-size or mid-size-to-large business,... Read More
For those who are unclear on the differences between the... Read More
The fact that a software tester is a most infamous... Read More
Software |