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.
premium house cleaning Wilmette ..New post-recession era has new features, which didn't exist in... Read More
Looks like Microsoft Great Plains becomes more... Read More
Just the thought of a duel-boot scares many people away,... Read More
Task Manager is a Windows system utility that displays thetasks... Read More
What is IRC?IRC is Internet Relay Chat. It is a... Read More
What is Tripwire?Tripwire is a form intrusion detection system (IDS)... Read More
When you buy a computer, it most likely comes with... Read More
You have gotten those E_Mails buy software at deep discounts.... Read More
Heard about the Quark "killer"?Adobe InDesign CS2. Will it really... Read More
Are Spreadsheets Robbing your Enterprise of Competitive Advantage?'90% of "average"... Read More
Microsoft Business Solutions CRM is now approaching the phase of... Read More
This article is the first of a series of articles... Read More
We were recently faced with a decision: either to let... Read More
.NET platform does not support multiple inheritance. Do not confuse... Read More
Should one use Windows Update?This topic has good and valid... Read More
Microsoft Business Solutions CRM is web-based CRM application, deploying all... Read More
An integral part of any quality CRM system is lead... Read More
Anyone who has ever used Microsoft Word knows that it... Read More
Icons are used everywhere; right from software applications, to internet... Read More
When making a decision to buy any piece of software... Read More
Are you ready? SQL Server 2005, the next-generation data management... Read More
The stakes are high when considering security, privacy, and savings,... Read More
The major reason I recommend getting your hands on real... Read More
There are several kinds of software piracy. The bottom line... Read More
Great Plains Integration Manager scripting and translation - overview for... Read More
personalized cleaning services Deerfield ..Microsoft Business Solutions Great Plains is very generic accounting application... Read More
Three highly respected names in Human Resources have joined forces... Read More
What is 'adware'?Adware is basically software or scripts that are... Read More
I've been active in the Cisco Certification track for four... Read More
Microsoft Business Solutions Great Plains, former Great Plains Software Dynamics... Read More
Handling character strings in Java is supported through two final... Read More
Make-or-Break Factors in Success and ProfitabilityFor quick printers, estimating can... Read More
If someone entered your home, uninvited and installed numerous cameras... Read More
While I was in college, if you would have asked... Read More
You've finally created databases that you can actually use to... Read More
MicroWorld Technologies, Inc. the leading solutions provider in the area... Read More
IntroductionPHP can be used for a lot of different things,... Read More
In 2004 Oracle, Inc. made its new step toward J2EE... Read More
As seeing large number of implementations ? in our case... Read More
Mike Dunville* had a decision to make. As the new... Read More
With any good luck and a good amount of hard... Read More
Spyware is like the new technological nuclear weapon on the... Read More
Traditionally we were considering functionally rich systems, such as SAP,... Read More
Microsoft Great Plains is becoming more and more popular and... Read More
Microsoft Business Solutions Navision is main ERP application for European,... Read More
While Ukraine is becoming a new popular IT outsourcing destination,... Read More
Finding the best spyware removers to detect and remove spyware... Read More
Small can be beautiful! Working with Knoppix for the past... Read More
Sometimes your PC will start acting strange for no apparent... Read More
Combining Microsoft Business Solutions Great Plains ERP with non-Microsoft Business... Read More
Software |