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.
Wood Dale Chicago prom limo .. Lockport Chicago limo O’HareBeginning with Domino version R4 it has integration with the... Read More
Anti-virus software is used to find, remove or fix files... Read More
Blue Cross and Blue Shield of Hawaii (HMSA) found itself... Read More
Innovative Maintenance Systems (IMS) is one company that offers solutions... Read More
Since technology changes so quickly, it is hard to begin... Read More
Microsoft Business Solutions products: Great Plains, MS CRM, Navision, Axapta,... Read More
The first thing that you will notice about Linux Red... Read More
.Net Framework is a platform or development environment to seamlessly... Read More
How many steps does it take you to locate and... Read More
MS CRM is very close to document workflow automation, including... Read More
OEComplete is a utility for managing the personal information of... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
Language development computer: Computer-based method for aiding language development seems... Read More
It is now common thing when large corporation selects mid-market... Read More
There are several kinds of software piracy. The bottom line... Read More
Microsoft Great Plains serves majority of US based horizontal and... Read More
Usually workflow & messaging is realized in CRM and then... Read More
So, why should you use any O/R mapping tool? I... Read More
Homeland security, airport security, Internet security ??" these days we???re... Read More
2005 ? Back to the Future.What does the future hold?... Read More
Microsoft Business Solutions CRM is present several years on the... Read More
Let's first look at your ERP system selection (without Retail... Read More
Software Engineering is the Systematic Approach for analysis design implementation... Read More
The Windows registry is a huge database that ensures normal... Read More
There are many commands that are used in linux on... Read More
Antigo wedding limo ..Fleet Maintenance Management is a critical position in any company... Read More
In our small article we'll consider Microsoft Business Solutions Great... Read More
Microsoft Business Solutions Great Plains as new ERP for multinational... Read More
Hi, Guys,I believe a lot of programmers are trying to... Read More
Microsoft-Outlook is a pretty amazing program. So much more than... Read More
The Windows registry is a huge database that ensures normal... Read More
It would be easy to think, like most people apparently... Read More
Words we choose to describe things and phenomena often show... Read More
When Great Plains Software was designing and developing Great Plains... Read More
Internet worms. Is your PC infected?If your computer has become... Read More
This article is the first of a series of articles... Read More
Now is the time to look at an alternative to... Read More
Professional services firm cuts costs and improves productivity with integrated... Read More
Accounts payable is just one area of office management where... Read More
Microsoft Great Plains is now standard mid-market ERP application, serving... Read More
According to a survey conducted by InfoTrends/CAP Ventures entitled "Content-Centric... Read More
If you would like to pick something from Microsoft, or... Read More
.Net Framework is a platform or development environment to seamlessly... Read More
While Adobe is the most known maker of PDF tools,... Read More
ERP Consulting industry is on the way to serve clients... Read More
TCO (Total Cost Ownership) is the buzzword in... Read More
While Ukraine is becoming a new popular IT outsourcing destination,... Read More
Microsoft Great Plains and Microsoft Retail Management System (Microsoft RMS)... Read More
When you visit department stores and see that majority of... Read More
Imagine something that follows you home and sets itself up... Read More
Software |