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.
move in cleaning service Wilmette ..Great Plains Integration Manager scripting and translation - overview for... Read More
The major reason I recommend getting your hands on real... Read More
Spyware is software or hardware installed on a computer without... Read More
Remember old good days when your company probably had Great... Read More
Crystal Reports is the most flexible tool on the market... Read More
Accounts payable is just one area of office management where... Read More
MS CRM is very close to document workflow automation, including... Read More
Once upon a time not so long ago, there was... Read More
Spyware is like the new technological nuclear weapon on the... Read More
If you are in the market for new staffing software,... Read More
Shareware is software that you can try before you buy;... Read More
IntroductionDuring the early years of our modern computer era, very... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
One day, you suddenly realize that your computer started to... Read More
Bar charts, bar graphs, and any other chart or graph... Read More
Microsoft CRM and IBM Lotus Notes Domino seem to be... Read More
Features Additionally, Vista will include many other new features.Aero Vista... Read More
In linux, one of great commands for finding out information... Read More
Microsoft Great Plains is now targeting large and midsize businesses... Read More
This short paper will expand on two key reasons to... Read More
Corporate ERP/MRP selection might be tough one, especially considering very... Read More
Think of this, first we had the HAM Radio, then... Read More
ERP (Enterprise Resource Planning) Overview covers What is ERP, Brief... Read More
Microsoft Great Plains may be recommended for international freight forwarding... Read More
IntroductionSurprised, by the title? well, this is a tour of... Read More
green cleaning service Lincolnshire ..Microsoft Business Solutions CRM is present several years on the... Read More
Just the thought of a duel-boot scares many people away,... Read More
Language development computer: Computer-based method for aiding language development seems... Read More
Looks like Microsoft Great Plains becomes more and more... Read More
When you visit department stores and see that majority of... Read More
Do you remember that frustrating feeling when you find an... Read More
User interfaces and accessibility are some of the most important... Read More
Microsoft Great Plains, designed back in 1990th as database transferable... Read More
Before being able to choose a secure Internet communication system,... Read More
Microsoft Business Solutions Great Plains has substantial market share among... Read More
Music downloads are off the charts! We're listening to digital... Read More
Not every software testing project can or should be automated.... Read More
This article is for advanced Microsoft CRM SDK C# developers.... Read More
Adware is a type of Spyware program that displays some... Read More
Microsoft Business Solutions Great Plains is Dexterity-written application and currently... Read More
Since technology changes so quickly, it is hard to begin... Read More
Microsoft Business Solutions Great Plains has I'd say end user... Read More
In our case ? we serve Microsoft Business Solutions ERP... Read More
In the previous ISDN article, we looked at how and... Read More
Microsoft Great Plains has full-featured Manufacturing suite of modules: Capacity... Read More
The software giants don't do everything and don't always produce... Read More
When you double-click a layer in the Layer Palette, you... Read More
Sometimes your PC will start acting strange for no apparent... Read More
FTP stands for "file transfer protocol". FTP is basically a... Read More
There are plenty of articles out there about how to... Read More
Software |