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/csh arp/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 (www.albaspectrum.com), he is Dexterity, SQL, VB/C#.Net, Crystal Reports and Microsoft CRM SDK developer.
|
|
|
|
|
|
|
|
|
|
|


Microsoft CRM and IBM Lotus Notes Domino seem to be... Read More
The intentions of this short tutorial are not to teach... Read More
Combining Microsoft Business Solutions Great Plains ERP with non-Microsoft Business... Read More
Learning how to program software seems like a daunting task... Read More
Executive SummaryAn effective plan for entering, cleaning and updating the... Read More
Document Manager and Version HistoryIn previous articles I have discussed... Read More
Microsoft Business Solutions Great Plains, Navision, Axapta, Solomon and CRM... Read More
While Adobe is the most known maker of PDF tools,... Read More
Pirated software is on the increase and now accounts for... Read More
Microsoft bought Navision, Denmark based software development company, along with... Read More
Just when you thought you were Web savvy, one more... Read More
Although statistics often is blamed for various deadly sins --... Read More
Before September of 1995, Microsoft ignored the Internet because their... Read More
The major reason I recommend getting your hands on real... Read More
Most people understand that the "hardware" part of their computer... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
Microsoft Business Solutions products: Great Plains, MS CRM, Navision, Axapta,... Read More
Microsoft Business Solutions CRM and IBM Lotus Notes Domino, being... Read More
Programming Help for BeginnersWe write programs to instruct computers. When... Read More
Microsoft Business Solutions Great Plains is very good fit for... Read More
Microsoft Business Solutions Great Plains and MS CRM (client relation... Read More
Microsoft CRM has built-in conversion tool, however you should probably... Read More
Following tips help you to learn a software in lesser... Read More
If you are in the market for new staffing software,... Read More
IntroductionPHP can be used for a lot of different things,... Read More
In part III of this ISDN primer, we learned that... Read More
If you're online using a dialup Internet connection, you'll probably... Read More
Are you a whiz at calculating financial information? Not the... Read More
Microsoft Business Solutions CRM is present several years on the... Read More
Is your PC is slow and wimpy? Then you need... Read More
Domino server is a buffer between the operation system and... Read More
We all already got used to computer monitoring both at... Read More
All your software is stored on a hard-drive. But how... Read More


Looks like Microsoft Great Plains becomes more and more... Read More
Fortunately one of the most common reasons cited for the... Read More
RSS (Really Simple Syndication) is a way for a site... Read More
MSN messenger is a pretty cool invention. I mean I'm... Read More
The software giants don't do everything and don't always produce... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
FTP stands for "file transfer protocol". FTP is basically a... Read More
1. With mapping software you can create a report that... Read More
Since technology changes so quickly, it is hard to begin... Read More
Here is some free software tools to help you build... Read More
OEComplete is a utility for managing the personal information of... Read More
The objective for Zandi Digital is to make available clever... Read More
ERP (Enterprise Resource Planning) Overview covers What is ERP, Brief... Read More
Currently Microsoft Business Solutions is on the way of creating... Read More
Writing software manuals is boring, isn't it? We often think:... Read More
If you copy something from a Web site or elsewhere...... Read More
In our case ? we serve Microsoft Business Solutions ERP... Read More
It's not very often I get excited about a software... Read More
Just the thought of a duel-boot scares many people away,... Read More
When you double-click a layer in the Layer Palette, you... Read More
Upgrading. Downtime. Maintenance. Hardware obsolescence. Implementation issues. The litany of... Read More
We are in a transition phase in the Managerial Administration... Read More
Great Plains Integration Manager scripting and translation - overview for... Read More
If you have been using the Internet for any amount... Read More
Does Microsoft care for WebmastersIt's always been a problem with... Read More
Not all of us have the luxury of working both... Read More
Stop the Runaway MouseWhat's the "runaway mouse?" You've seen it...you... Read More
Task Manager is a Windows system utility that displays thetasks... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
Scrapbooks are very popular these days. I think that almost... Read More
Remember back in the days where screensavers were the coolest... Read More
So, why should you use any O/R mapping tool? I... Read More
Microsoft Business Solutions CRM is present several years on the... Read More
Software |