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.
move out cleaning service Glencoe ..Your computer cost you from hundreds to thousands of dollars,... Read More
We'll give you non formal view, based on our consulting... Read More
Microsoft Business Solutions Great Plains, former Great Plains Software Dynamics... Read More
Features Additionally, Vista will include many other new features.Aero Vista... Read More
Microsoft Business Solutions Great Plains has substantial market share among... Read More
Introduction To ISDN, Part III: Configuring PPP PAP AuthenticationNow we... Read More
Microsoft Great Plains is becoming more and more popular and... Read More
For those who still don't know, Microsoft Publisher helps computer... Read More
Microsoft Business Solutions CRM is present several years on the... Read More
How to delete the user? This is the first problem... Read More
While I was preparing some personal background information for a... Read More
This is a short article, written in question/answer/FAQ style to... Read More
Microsoft Great Plains is one of the Microsoft Business Solutions... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
Small can be beautiful! Working with Knoppix for the past... Read More
"Pfishing", sometimes spelled "Phishing", is a word that's used to... Read More
Are you a whiz at calculating financial information? Not the... Read More
In part III of this ISDN primer, we learned that... Read More
Microsoft Great Plains might be considered as ERP platform to... Read More
ERP (Enterprise Resource Planning) Overview covers What is ERP, Brief... Read More
Microsoft Great Plains and Microsoft CRM become more and more... Read More
Adware is a type of Spyware program that displays some... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
Microsoft Business Solutions Great Plains is very generic accounting application... Read More
ERP Consulting industry is on the way to serve clients... Read More
house cleaning company Bannockburn ..What is Software?Software is a set of instruction written to... Read More
Handling character strings in Java is supported through two final... Read More
A UNIX Shell is in simplest terms, a command line... Read More
This is a short article, written in question/answer/FAQ style to... Read More
Assertion facility is added in J2SE 1.4. In order to... Read More
When you own a small business, time is money. And... Read More
Microsoft Business Solutions Great Plains was historically designed to serve... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
In order to implement VLANs in a network environment, you'll... Read More
The vast majority of us will have, at some point,... Read More
No matter how much you enjoy your favorite screensavers, sometimes... Read More
Healthcare facilities such as clinics, hospitals, and biomedical laboratories can... Read More
It could just be me, but my experiences with document... Read More
I have always had a tendency to focus on the... Read More
Running Applications in Compatibility Mode With Windows XP, you can... Read More
Microsoft Business Solutions Small Business Manager is scaled down Great... Read More
Microsoft PowerPoint has dramatically changed the way in which academic... Read More
Disclaimer: All the thoughts expressed are my views only! Your... Read More
Microsoft Business Solutions Navision serves both European and American megamarkets.... Read More
Language development computer: Computer-based method for aiding language development seems... Read More
OEComplete is a utility for managing the personal information of... Read More
I suggest that you do not spend a lot of... Read More
Bar charts, bar graphs, and any other chart or graph... Read More
New post-recession era has new features, which didn't exist in... Read More
Enabling Chinese input is quick and easy, there are only... Read More
Software |