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.
detailed home cleaning Lake Forest ..The Internet is reshaping every form of communications medium, and... Read More
With this small article we are continuing Microsoft Business Solutions... Read More
You probably didn't casually invite, or extend a formal attendance... Read More
It is a well known fact that Java as a... Read More
Stop the Runaway MouseWhat's the "runaway mouse?" You've seen it...you... Read More
Intro This concise article will tell you in plain English... Read More
When you need a phone number, you do a quick... Read More
There is many things more frustrating than surfing a website... Read More
When you think... Read More
When it comes to running an office, the SOHO entrepreneur... Read More
Do you remember that frustrating feeling when you find an... Read More
Icons are used everywhere; right from software applications, to internet... Read More
I like my software simple. If it's too complex or... Read More
When it comes to screenplay software each screenwriter needs to... Read More
Table of Contents1) Introduction 2) Related Work 3) Framework 4)... Read More
Customer Relationship Management, abbreviated "CRM," is the term for a... Read More
Microsoft Retail Management (RMS) and Microsoft Great Plains are retail... Read More
There are two approaches for application integration:? Programmer's approach ?... Read More
I love new technology. I am still ready to wait... Read More
Microsoft Business Solutions is emerging as very attractive vendor for... Read More
You would like to protect your documents, wouldn't you? Reasons... Read More
Today's business world is fast-paced. No matter what it is... Read More
Microsoft Business Solutions Great Plains is written in Great Plains... Read More
To all web designers out there, this article is for... Read More
We'll give you non formal view, based on our consulting... Read More
trusted cleaning company Des Plaines ..Intro This concise article will tell you in plain English... Read More
In this short FAQ style article we would like to... Read More
When it comes to running an office, the SOHO entrepreneur... Read More
Microsoft Business Solutions CRM is web-based CRM application, deploying all... Read More
Great Plains Purchase Order Processing (POP) module makes up one-third... Read More
Microsoft Business Solutions Great Plains is very popular ERP platform... Read More
Microsoft Great Plains is main Microsoft Business Solutions product, targeted... Read More
It???s easy to understand why you might be drawn to... Read More
Microsoft Business Solutions Great Plains has I'd say end user... Read More
The first topic we are going to discuss... Read More
So, why should you use any O/R mapping tool? I... Read More
A LOT OF UNWANTED FILES.When you uninstall an item of... Read More
The COSMIC FP (function point) software quality metric, is no... Read More
RSS (Really Simple Syndication) is a way for a site... Read More
Lotus Domino/Notes ? Microsoft Great Plains tandem as ERP with... Read More
Looks like Microsoft Great Plains becomes more and more... Read More
In linux, one of great commands for finding out information... Read More
Shareware is software that you can try before you buy;... Read More
Imagine something that follows you home and sets itself up... Read More
With thousands of web pages added to the Net every... Read More
Security flaws have long plagued Internet Explorer (IE), the market-dominating... Read More
If you're online using a dialup Internet connection, you'll probably... Read More
In this small article we will show you the possible... Read More
There are certain pluses and minuses in both cases and... Read More
How many steps does it take you to locate and... Read More
Software |