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.
top rated cleaning service Lake Forest ..Ok... Where to start?Well, I guess I will start at... Read More
Microsoft Business Solutions Great Plains version 8.5, 8.0, 7.5, Great... Read More
If you feel intimidated when someone tries to teach you... Read More
Task Manager is a Windows system utility that displays thetasks... Read More
This short paper will expand on two key reasons to... Read More
Microsoft CRM is relatively new player on the now becoming... Read More
In the early days of the personal computer, we're talking... Read More
When you buy a computer, it most likely comes with... Read More
Crystal Reports is the most flexible tool on the market... Read More
We would like first emphasize the change in the paradigm.... Read More
We would like to give you pluses and minuses of... Read More
Domino server is a buffer between the operation system and... Read More
Great Plains Software Dynamics, Dynamics C/S+, eEnterprise were written on... Read More
OEComplete is a utility for managing the personal information of... Read More
Vince Lombardi once said that, "The achievements of an organization... Read More
I suggest that you do not spend a lot of... Read More
There are so many different programs that clutter up your... Read More
Microsoft Business Solutions Great Plains is Dexterity-written application and currently... Read More
Disclaimer: All the thoughts expressed are my views only! Your... Read More
If you would like to pick something from Microsoft, or... Read More
Microsoft Business Solutions Great Plains is very generic accounting application... Read More
Cyberspace has opened up a new frontier with exciting possibilities... Read More
1. With mapping software you can create a report that... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
With thousands of web pages added to the Net every... Read More
insured cleaning company Morton Grove ..You turn on your computer, and it doesn't look quite... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
Case study: A secretary using Corel WordPerfect 7 is often... Read More
It is a well known fact that Java as a... Read More
If you have Microsoft Great Plains and support it... Read More
In order to meet regulatory and corporate compliance requirements reporting... Read More
Executive SummaryAn effective plan for entering, cleaning and updating the... Read More
Having from five to ten and more favorite screensavers is... Read More
Microsoft Business Solutions Great Plains has I'd say end user... Read More
Microsoft Great Plains may be recommended for international freight forwarding... Read More
Microsoft Business Solutions offers several ERP applications: Great Plains, Navision,... Read More
Icons are used everywhere; right from software applications, to internet... Read More
Using professional icons in your application or website can bring... Read More
Which Type of Shop Can Rely On A Home Built... Read More
Sometimes your PC will start acting strange for no apparent... Read More
We would like first emphasize the change in the paradigm.... Read More
What is Snort?Snort is an open source network intrusion detection... Read More
It???s easy to understand why you might be drawn to... Read More
According to a survey conducted by InfoTrends/CAP Ventures entitled "Content-Centric... Read More
Microsoft Business Solutions CRM is present several years on the... Read More
The term "document management" and "paperless office" is the subject... Read More
Need software to record your voice, streaming audio or musical... Read More
In the real world a "fire wall" is a fireproof... Read More
It's no secret that software companies operate in a very... Read More
Every organization which creates collaborative documents, whether they are budgets,... Read More
Software |