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.
housekeepers near Buffalo Grove ..In the new era of internet marketing the problem of... Read More
The vast majority of us will have, at some point,... Read More
As you probably know, when Microsoft purchased Great Plains Software... Read More
Programming Help for BeginnersWe write programs to instruct computers. When... Read More
The various resume software offered, particularly on the internet, can... Read More
Microsoft Business Solutions Great Plains is written in Great Plains... Read More
This article is the fourth of a series of articles... Read More
Microsoft Business Solutions Great Plains version 8.5, 8.0, 7.5, Great... Read More
Former Great Plains Software Dynamics/eEnterprise and currently Microsoft Business Solutions... Read More
All of us know that Microsoft bought former Great Plains... Read More
Microsoft Business Solutions CRM and IBM Lotus Notes Domino, being... Read More
Microsoft Business Solutions Great Plains was designed back in the... Read More
If you feel intimidated when someone tries to teach you... Read More
Every organization which creates collaborative documents, whether they are budgets,... Read More
Microsoft Great Plains could be tuned and setup to fit... Read More
Great Plains Software Dynamics, Dynamics C/S+, eEnterprise were written on... Read More
For a long time now Microsoft's Internet Explorer has ruled... Read More
Microsoft Great Plains ? ERM from Microsoft Business Solutions and... Read More
If you have Great Plains Dynamics/eEnterprise (version 6.0 or earlier)... Read More
Our hosted solution allow you to run your own search... Read More
Just stress testing one of the latest Linux distributions. Been... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
When it comes to screenplay software each screenwriter needs to... Read More
Creating a new markup language.Introduction.General Reuse Markup Langauge, or GRML,... Read More
In the case when you represent mid-size or mid-size-to-large business,... Read More
custom home cleaning Mundelein ..Handling character strings in Java is supported through two final... Read More
Three highly respected names in Human Resources have joined forces... Read More
Microsoft Business Solutions ? Navision is an integrated solution for... Read More
With this small article we are continuing Microsoft Business Solutions... Read More
Microsoft CRM is new player on the CRM software... Read More
Microsoft Business Solutions Great Plains is mid and even corporate... Read More
Not all of us have the luxury of working both... Read More
Every organization which creates collaborative documents, whether they are budgets,... Read More
1. With mapping software you can create a report that... Read More
Microsoft Great Plains is one of three Microsoft Business Solutions... Read More
Microsoft Great Plains - Microsoft Business Solutions accounting and ERP... Read More
In this short FAQ style article we would like to... Read More
In our small article we'll consider Microsoft Business Solutions Great... Read More
What is Spyware?Spyware monitors your surfing habits and sends the... Read More
Microsoft Great Plains serves majority of US based horizontal and... Read More
Great Plains Integration Manager scripting and translation - overview for... Read More
Our hosted solution allow you to run your own search... Read More
Microsoft Great Plains ? ERM from Microsoft Business Solutions and... Read More
Microsoft CRM is winning market share step-by-step from such the... Read More
In part III of this ISDN primer, we learned that... Read More
Shareware is software that you can try before you buy;... Read More
Combining Microsoft Business Solutions Great Plains ERP with non-Microsoft Business... 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
It???s easy to understand why you might be drawn to... Read More
Software |