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.
personalized cleaning services Des Plaines ..Microsoft Great Plains and Microsoft Retail Management System (Microsoft RMS)... Read More
The Windows registry is a huge database that ensures normal... Read More
Bad News - the Threat is Bigger than it SeemedHow... Read More
Homeland security, airport security, Internet security ??" these days we???re... Read More
Microsoft Business Solutions is now in process of creating so... Read More
In the previous ISDN article, we looked at how and... Read More
If you are in the market for new staffing software,... Read More
As we could imagine, if you are reading this article... Read More
Imagine something that follows you home and sets itself up... Read More
Before September of 1995, Microsoft ignored the Internet because their... Read More
We would like to give you pluses and minuses of... Read More
When making a decision to buy any piece of software... Read More
It would be easy to think, like most people apparently... Read More
Great Plains Purchase Order Processing (POP) module makes up one-third... Read More
Healthcare facilities such as clinics, hospitals, and biomedical laboratories can... Read More
If you company is small or mid-size special products or... Read More
If you have Microsoft Great Plains and support it for... Read More
How would you like to prevent spyware and adware from... Read More
Microsoft Business Solutions Great Plains was purchased from Great Plains... Read More
I started using PIP (Picture It Publishing) Platinum 2002 right... Read More
One of the main reasons business owners and entrepreneurs use... Read More
It could just be me, but my experiences with document... Read More
We would like first emphasize the change in the paradigm.... Read More
You turn on your computer, and it doesn't look quite... Read More
You've finally created databases that you can actually use to... Read More
family-safe home cleaners Arlington Heights ..Great Plains Accounting, accounting package for mid-size and small companies... Read More
Bar charts, bar graphs, and any other chart or graph... Read More
C/SIDE (Client/Server Integrated Development Environment) - The core of... Read More
Every day millions of new web documents emerge on the... Read More
All of us know that Microsoft bought former Great Plains... Read More
Just imagine: you are walking, say, towards your car, and... Read More
Microsoft Business Solutions offers several ERP applications: Great Plains, Navision,... Read More
If you company is small or mid-size special products or... Read More
MSN messenger is a pretty cool invention. I mean I'm... Read More
Icons are used everywhere; right from software applications, to internet... Read More
Language development computer: Computer-based method for aiding language development seems... Read More
IntroductionSurprised, by the title? well, this is a tour of... Read More
Microsoft CRM is CRM answer from Microsoft and attempt to... Read More
Microsoft CRM is CRM answer from Microsoft Business Solutions. If... Read More
Which Type of Shop Can Rely On A Home Built... Read More
A UNIX Shell is in simplest terms, a command line... Read More
The most important things you can do for your computer... Read More
Microsoft Business Solutions Great Plains is very generic accounting application... Read More
You've finally created databases that you can actually use to... Read More
Currently Microsoft Business Solutions is on the way of creating... Read More
Pirated software is on the increase and now accounts for... Read More
Microsoft Great Plains fits to majority of horizontals and retail... Read More
Our hosted solution allow you to run your own search... Read More
One of the main reasons business owners and entrepreneurs use... Read More
Best Software Act! is very popular CRM for small and... Read More
Software |