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.
home cleaning services Deerfield ..Microsoft Business Solutions Great Plains, former Great Plains Software Dynamics... Read More
In the new era of internet marketing the problem of... Read More
In this small article we will show you the possible... Read More
New post-recession era has new features, which didn't exist in... Read More
Once upon a time not so long ago, there was... Read More
In the case when you represent mid-size or mid-size-to-large business,... Read More
As you probably know, when Microsoft purchased Great Plains Software... Read More
"Pfishing", sometimes spelled "Phishing", is a word that's used to... Read More
Spyware is like the new technological nuclear weapon on the... Read More
Microsoft Business Solutions Great Plains has several options to enable... Read More
Document Management or Enterprise Information Management is perhaps one of... Read More
In the previous ISDN article, we looked at how and... Read More
Learning how to program software seems like a daunting task... Read More
Microsoft Great Plains fits to majority of industries, in the... Read More
If you have Microsoft Great Plains and support it... Read More
Ad-Aware and Spybot are probably the two most well known... Read More
Sticky Noteshttp://www.deprice.com/stickynote.htmWith StickyNote 9.0, you can create beautiful 3D notes... Read More
When Windows fails to boot it is normally caused by... Read More
Let's say that you have a software project that's under... Read More
Did you ever give a thought to the number of... Read More
First we had the original Google search that evolved into... Read More
With many manufacturing shops heading over seas in favor of... Read More
Fortunately one of the most common reasons cited for the... Read More
Microsoft CRM is CRM answer from Microsoft Business Solutions. If... Read More
When Great Plains Software introduced the first graphical accounting application... Read More
recurring housekeeping Highland Park ..When you think... Read More
With any good luck and a good amount of hard... Read More
Having from five to ten and more favorite screensavers is... Read More
Configuring PPP PAP AuthenticationNow we know how the ISDN link... Read More
Microsoft Great Plains is one of three Microsoft Business Solutions... Read More
This article illustrates the best practices to improve the performance... Read More
As of now - Great Plains Dynamics/eEnterprise is transformed/renamed into... Read More
Microsoft Great Plains is now standard mid-market ERP application, serving... Read More
What is RAID RECOVERY?RAID stands for Redundant Array of Inexpensive... Read More
Considering whether or not your software company should hire a... Read More
MSN messenger is a pretty cool invention. I mean I'm... Read More
In the previous ISDN article, we looked at how and... Read More
Heard about the Quark "killer"?Adobe InDesign CS2. Will it really... Read More
Microsoft Great Plains is main Microsoft Business Solutions accounting package... Read More
When reading an article where some term is used often,... Read More
One of the things we can be as certain of... Read More
User interfaces and accessibility are some of the most important... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
Background: For many organizations like ours, the interim target of... Read More
This article is the third of a series of articles... Read More
I love new technology. I am still ready to wait... Read More
You turn on your computer, and it doesn't look quite... Read More
Whether you are an experienced web programmer or a complete... Read More
Creating a new markup language.Introduction.General Reuse Markup Langauge, or GRML,... Read More
XML Server can be a Web Server that stores the... Read More
Software |