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 cleaning services Winnetka ..Microsoft Great Plains serves the wide spectrum of horizontal markets.... Read More
The Windows Indexing Service provides you with the ability to... Read More
Microsoft Business Solutions CRM is present several years on the... Read More
Now there are Three Steps To Heaven Just listen and... Read More
Table of Contents1) Introduction 2) Related Work 3) Framework 4)... Read More
We all already got used to computer monitoring both at... Read More
Microsoft Business Solutions Great Plains, former Great Plains Software eEnterprise,... Read More
In the previous ISDN article, we looked at how and... Read More
Spyware and Adware infest over 90 percent of computers in... Read More
Many Webmasters have never bothered to view their website's server... Read More
The Microsoft system preparation utility for Windows 2000 is a... Read More
Microsoft PowerPoint has dramatically changed the way in which academic... Read More
How do you run a program on a remote server... Read More
Some companies that are in need of fleet management may... Read More
Should one use Windows Update?This topic has good and valid... Read More
The fact that a software tester is a most infamous... Read More
Our company, Novaprof Inc., developed unique software - DB Integration.... Read More
To all web designers out there, this article is for... Read More
Costs of fleet maintenance software can vary widely. It is... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
Words we choose to describe things and phenomena often show... Read More
Let us give you - developer some hints in the... Read More
eStore Advantage allows front-office applications to communicate with back-office business... Read More
The Software 2005 conference is now a wrap. This conference,... Read More
When it comes to screenplay software each screenwriter needs to... Read More
reliable maid service Lincolnshire ..As of now - Great Plains Dynamics/eEnterprise is transformed/renamed into... Read More
Some introduction into Great Plains Software products, now Microsoft Business... Read More
If you would like to pick something from Microsoft, or... Read More
Microsoft Business Solutions ? Great Plains is designed to meet... Read More
Remember old good days when your company probably had Great... Read More
I love new technology. I am still ready to wait... Read More
Formatting and reinstalling windows 98 is very easy if you... Read More
Microsoft CRM is CRM application, maintained and supported by Microsoft... Read More
Microsoft Great Plains has full-featured Manufacturing suite of modules: Capacity... Read More
If you are in the market for new staffing software,... Read More
The first thing that you will notice about Linux Red... Read More
Does Microsoft Have any Real Competition? Copyright (c) 2003 Gregory... Read More
Microsoft CRM is winning market share step-by-step from such the... Read More
There are many commands that are used in linux on... Read More
Are Spreadsheets Robbing your Enterprise of Competitive Advantage?'90% of "average"... Read More
Sticky Noteshttp://www.deprice.com/stickynote.htmWith StickyNote 9.0, you can create beautiful 3D notes... Read More
What is RAID RECOVERY?RAID stands for Redundant Array of Inexpensive... Read More
Whether you are a small consultancy firm, a medium sized... Read More
In order to implement VLANs in a network environment, you'll... Read More
People often ask me: What image file formats will Photoshop... Read More
Just imagine: you are walking, say, towards your car, and... Read More
Not every software testing project can or should be automated.... Read More
Task Manager is a Windows system utility that displays thetasks... Read More
Our hosted solution allow you to run your own search... Read More
Microsoft Great Plains and Microsoft Retail Management System (Microsoft RMS)... Read More
Software |