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.
limousine Ackley .. Lockport Chicago limo O’HareMicrosoft Business Solutions Great Plains is marketed for mid-size companies... Read More
MSN messenger is a pretty cool invention. I mean I'm... Read More
While I was in college, if you would have asked... Read More
So, why should you use any O/R mapping tool? I... Read More
Accounts payable is just one area of office management where... Read More
Great Plains Integration Manager scripting and translation - overview for... Read More
The intuitive algorithm.Roger Penrose considered it impossible. Thinking could never... Read More
Since Version 8.0 Microsoft Business Solutions Great Plains & Great... Read More
GroupwareThe internet is full of 1.5 million to 7 million... Read More
An integral part of any quality CRM system is lead... Read More
DBxtra goes ASPGetting to the information hidden within corporate databases... Read More
The Internet is reshaping every form of communications medium, and... Read More
A few months back I really got sick of my... Read More
Microsoft Great Plains could be tuned and setup to fit... Read More
Vince Lombardi once said that, "The achievements of an organization... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
We'll give you non formal view, based on our consulting... Read More
Microsoft Business Solutions Great Plains and MS CRM (client relation... Read More
Every day millions of new web documents emerge on the... Read More
Microsoft CRM is CRM application, maintained and supported by Microsoft... Read More
C++ Function templates are those functions which can handle different... Read More
The purpose of one of our projects was MS Exchange... Read More
CD and DVD replication is a process that works by... Read More
Upgrading. Downtime. Maintenance. Hardware obsolescence. Implementation issues. The litany of... Read More
Microsoft Business Solutions Great Plains, Solomon, Navision, Axapta, Microsoft CRM... Read More
shuttle from O'Hare Alexander ...NET platform does not support multiple inheritance. Do not confuse... Read More
In the new era of internet marketing the problem of... Read More
Spyware is software or hardware installed on a computer without... Read More
For a long time now Microsoft's Internet Explorer has ruled... Read More
First we had the original Google search that evolved into... Read More
No matter how much you enjoy your favorite screensavers, sometimes... Read More
Whether you need to close a sale, gather end-user feedback,... Read More
The Microsoft system preparation utility for Windows 2000 is a... Read More
With the advent of 'Service Pack 2' for Windows XP... Read More
Enabling Chinese input is quick and easy, there are only... Read More
Microsoft Great Plains fits to majority of horizontals and retail... Read More
You might think you don't need a firewall... Read More
Crystal Reports is the most flexible tool on the market... Read More
Small can be beautiful! Working with Knoppix for the past... Read More
Microsoft Business Solutions Great Plains might be considered as ERP... Read More
When you visit department stores and see that majority of... Read More
Sticky Noteshttp://www.deprice.com/stickynote.htmWith StickyNote 9.0, you can create beautiful 3D notes... Read More
Microsoft Business Solutions CRM and IBM Lotus Notes Domino, being... Read More
Ad-Aware and Spybot are probably the two most well known... Read More
Is your PC is slow and wimpy? Then you need... Read More
Spyware is like the new technological nuclear weapon on the... Read More
Learning how to program software seems like a daunting task... Read More
Several years ago Microsoft purchased Great Plains Software, then Navision... Read More
Buying accounting software is a major investment. It's an important... Read More
In this small article we will be looking at the... Read More
Software |