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.
non-toxic cleaning company Glencoe ...Since technology changes so quickly, it is hard to begin... Read More
Microsoft Business Solutions Great Plains has full-featured manufacturing set of... Read More
Microsoft Business Solutions Great Plains has Project Accounting module where... Read More
Your computer cost you from hundreds to thousands of dollars,... Read More
Microsoft Great Plains is one of the Microsoft Business Solutions... Read More
When you double-click a layer in the Layer Palette, you... Read More
You would like to protect your documents, wouldn't you? Reasons... Read More
As you probably know, when Microsoft purchased Great Plains Software... Read More
New post-recession era has new features, which didn't exist in... Read More
Microsoft Business Solutions Great Plains was designed back in the... Read More
There is many things more frustrating than surfing a website... Read More
If you feel intimidated when someone tries to teach you... Read More
I have always had a tendency to focus on the... Read More
Microsoft Business Solutions Great Plains was historically designed to serve... Read More
Following tips help you to learn a software in lesser... Read More
Is Photoshop CS2 worth the upgrade? You bet it is!... Read More
Research bears that less than 70 percent of development projects... Read More
So, you've bought a new Macintosh, and now you may... Read More
Spyware and malware are large problems for Internet users today... Read More
The destruction of the Soviet Union about 15 years ago,... Read More
For those who still don't know, Microsoft Publisher helps computer... Read More
Linux essentials:It's free for download but you have to pay... Read More
Many reasons made GBM a unanimous choice for experts, one... Read More
Logistics automation is often considered as barcoding extension to Sales... Read More
If you company is small or mid-size special products or... Read More
scheduled maid service Glenview ...The term "document management" and "paperless office" is the subject... Read More
Looks like Microsoft Great Plains becomes more and more... Read More
As you probably know, when Microsoft purchased Great Plains Software... Read More
Do you want to get quality software at a reasonable... Read More
Microsoft-Outlook is a pretty amazing program. So much more than... Read More
What is IRC?IRC is Internet Relay Chat. It is a... Read More
Microsoft Business Solutions Great Plains is very generic accounting application... Read More
After almost two decades of existence, Quark has become the... Read More
What is a Web Database?A web database is a database... Read More
After seeing many people complain about their weak Internet security... Read More
Follow the steps below to quickly design, generate, and deploy... Read More
Microsoft Business Solutions Great Plains version 8.5, 8.0, 7.5, Great... Read More
If you've been using MySQL database to store your important... Read More
You've finally created databases that you can actually use to... Read More
Microsoft Great Plains is one of three Microsoft Business Solutions... Read More
The destruction of the Soviet Union about 15 years ago,... Read More
When making a decision to buy any piece of software... Read More
If you have Microsoft Great Plains and support it for... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
If you look back to the history, you will see... Read More
Rapid Application Development (RAD) is a software development methodology. In... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
IBM Lotus Notes Domino and Microsoft CRM (Client Relation Management)... Read More
During the years of our consulting practice, which comes back... Read More
Handling character strings in Java is supported through two final... Read More
Software |