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.
apartment cleaning near Highland Park ..Collaboration SoftwareCollaboration Software, also known as group collaboration software or... Read More
Microsoft Great Plains, former Great Plains Software Dynamics / eEnterprise... Read More
Microsoft Business Solutions Great Plains, former Great Plains Software Dynamics/eEnterprise... Read More
According to a survey conducted by InfoTrends/CAP Ventures entitled "Content-Centric... Read More
Make-or-Break Factors in Success and ProfitabilityFor quick printers, estimating can... Read More
With this small article we are continuing Microsoft Business Solutions... Read More
What is Software?Software is a set of instruction written to... Read More
If you copy something from a Web site or elsewhere...... Read More
In the previous ISDN article, we looked at how and... Read More
Microsoft Great Plains has full-featured Manufacturing suite of modules: Capacity... Read More
Does Microsoft Have any Real Competition? Copyright (c) 2003 Gregory... Read More
Microsoft Business Solutions Small Business Manager is Great Plains Dexterity... Read More
If you company is small or mid-size special products or... Read More
Vince Lombardi once said that, "The achievements of an organization... Read More
The first topic we are going to discuss... Read More
Security flaws have long plagued Internet Explorer (IE), the market-dominating... Read More
Microsoft Retail Management (RMS) and Microsoft Great Plains are retail... Read More
Internet worms. Is your PC infected?If your computer has become... Read More
At the end of XX century, in the late 1990th... Read More
Most computer users use spreadsheets software such as Microsoft Excel... Read More
MSN messenger is a pretty cool invention. I mean I'm... Read More
There are so many different programs that clutter up your... Read More
Microsoft Business Solutions Great Plains fits to majority of horizontal... Read More
Microsoft bought Navision, Denmark based software development company, along with... Read More
For a windows user like me, just can watch with... Read More
cleaning lady near Arlington Heights ..Program Flow is what you think it is. How the... Read More
New post-recession era has new features, which didn't exist in... Read More
Microsoft Retail Management System serves retail single store as well... Read More
Microsoft Business Solutions Great Plains, Solomon, Navision, Axapta, Microsoft CRM... Read More
Microsoft Business Solutions Great Plains was historically designed to serve... Read More
MicroWorld Technologies, Inc. the leading solutions provider in the area... Read More
If you're online using a dialup Internet connection, you'll probably... Read More
Features Additionally, Vista will include many other new features.Aero Vista... Read More
It is really interesting that a bug can create problem... Read More
If you've been using MySQL database to store your important... Read More
Which Type of Shop Can Rely On A Home Built... Read More
Have you ever noticed that when you look at your... Read More
Microsoft Great Plains has substantial mid-market share in the USA... Read More
C++ Function templates are those functions which can handle different... Read More
Microsoft Great Plains, designed back in 1990th as database transferable... Read More
In the Clinton era the status quo was simple: you... Read More
Microsoft Client Relation Management system (Microsoft CRM) and Microsoft RMS... Read More
Microsoft Business Solutions Great Plains has Project Accounting module where... Read More
In the early days of the personal computer, we're talking... Read More
GroupwareThe internet is full of 1.5 million to 7 million... 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
TCO (Total Cost Ownership) is the buzzword in... Read More
.NET platform does not support multiple inheritance. Do not confuse... Read More
As Mozilla Firefox nears 10% market share, with well over... Read More
Software |