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.
recurring cleaning service Wilmette ..The most important benefit of XML is its simplicity. Though... Read More
Just imagine: you are walking, say, towards your car, and... Read More
An operating system (abbreviated OS) is essentially the path through... Read More
The vast majority of us will have, at some point,... Read More
We were recently faced with a decision: either to let... Read More
I've been active in the Cisco Certification track for four... Read More
Microsoft Business Solutions ? Great Plains has captured the US... Read More
Looks like Microsoft Great Plains becomes more... Read More
When you think... Read More
Many Webmasters have never bothered to view their website's server... Read More
Considering whether or not your software company should hire a... Read More
We are in a transition phase in the Managerial Administration... Read More
Learning how to program software seems like a daunting task... Read More
Most people don't use Photoshop to its fullest capabilities. Here... Read More
We've all seen the ads on TV for Netzero 3G.... Read More
Google Inc. has launched a new software package that allows... Read More
The destruction of the Soviet Union about 15 years ago,... Read More
This tutorial covers OLAP solutions used by Data warehouses and... Read More
GroupwareThe internet is full of 1.5 million to 7 million... Read More
Research bears that less than 70 percent of development projects... Read More
Midsize business or non-profit organization should decide if one-vendor solution... Read More
Let us give you - developer some hints in the... Read More
Although we don't know whether Microsoft ever envisioned such a... Read More
What is Colossus?Colossus is software licensed to about twenty-five insurance... Read More
Remember old good days when your company probably had Great... Read More
reliable maid service Morton Grove ..Microsoft Business Solutions products: Great Plains, MS CRM, Navision, Axapta,... Read More
Mapping Software Improves Data VisualizationFrom the outset, it is important... Read More
What is Colossus?Colossus is software licensed to about twenty-five insurance... Read More
If you have been using the Internet for any amount... Read More
If you copy something from a Web site or elsewhere...... Read More
In this article you will find some background information about... Read More
Great Plains Software Dynamics, Dynamics C/S+, eEnterprise were written on... Read More
Microsoft Business Solutions Great Plains is very generic accounting application... Read More
One day, you suddenly realize that your computer started to... Read More
Microsoft Business Solutions Small Business Manager is Great Plains Dexterity... Read More
Mike Dunville* had a decision to make. As the new... Read More
Just imagine: you are walking, say, towards your car, and... Read More
We will base our prognosis on our Microsoft Business Solutions... Read More
Small can be beautiful! Working with Knoppix for the past... Read More
There are several kinds of software piracy. The bottom line... Read More
If you look back to the history, you will see... Read More
2005 ? Back to the Future.What does the future hold?... Read More
Just the thought of a duel-boot scares many people away,... Read More
Microsoft CRM is CRM answer from Microsoft Business Solutions. If... Read More
Considering whether or not your software company should hire a... Read More
Microsoft Business Solutions Great Plains, Navision, Axapta, Solomon and CRM... Read More
Microsoft Business Solutions ? Navision is an integrated solution for... Read More
Microsoft Great Plains as ERP and Microsoft CRM as... Read More
First we had the original Google search that evolved into... Read More
Microsoft Client Relation Management system (Microsoft CRM) and Microsoft RMS... Read More
Software |