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.
Mokena prom limo .. Lockport Chicago limo O’HareWhat is Software?Software is a set of instruction written to... Read More
MSN messenger is a pretty cool invention. I mean I'm... Read More
#5 All your hardware components like Printers, PCs etc come... Read More
Assertion facility is added in J2SE 1.4. In order to... Read More
If you have Great Plains Dynamics/eEnterprise (version 6.0 or earlier)... Read More
Java has come along a long way. Many would agree... Read More
So, why should you use any O/R mapping tool? I... Read More
What is 'adware'?Adware is basically software or scripts that are... Read More
Buying accounting software is a major investment. It's an important... Read More
Does Microsoft Have any Real Competition? Copyright (c) 2003 Gregory... Read More
How to delete the user? This is the first problem... Read More
Microsoft Great Plains has full-featured Manufacturing suite of modules: Capacity... Read More
Microsoft Business Solutions Great Plains serves multiple industries in the... Read More
We all already got used to computer monitoring both at... Read More
Let's say that you have a software project that's under... Read More
CD and DVD replication is a process that works by... Read More
With many manufacturing shops heading over seas in favor of... Read More
Shareware has been fighting the stigma of being misunderstood for... Read More
IBM Lotus Notes Domino and Microsoft CRM (Client Relation Management)... Read More
After almost two decades of existence, Quark has become the... Read More
The most important benefit of XML is its simplicity. Though... Read More
Traditionally we were considering functionally rich systems, such as SAP,... Read More
Features Additionally, Vista will include many other new features.Aero Vista... Read More
ERP is the acronym of Enterprise Resource Planning. Multi-module ERP... Read More
The purpose of one of our projects was MS Exchange... Read More
Mokena Chicago limo O'Hare ..If you're online using a dialup Internet connection, you'll probably... Read More
Just when you thought you were Web savvy, one more... Read More
Words we choose to describe things and phenomena often show... Read More
Is Photoshop CS2 worth the upgrade? You bet it is!... Read More
Security flaws have long plagued Internet Explorer (IE), the market-dominating... Read More
Microsoft Great Plains is main Microsoft Business Solutions accounting package... Read More
Scrapbooks are very popular these days. I think that almost... Read More
Research bears that less than 70 percent of development projects... Read More
To all web designers out there, this article is for... Read More
Are you a whiz at calculating financial information? Not the... Read More
Executive SummaryAn effective plan for entering, cleaning and updating the... Read More
TCO (Total Cost Ownership) is the buzzword in... Read More
Microsoft has never released a service pack for Windows98 SE,... Read More
It???s easy to understand why you might be drawn to... Read More
Our opinion is based on our Microsoft Business Solutions Great... Read More
IntroductionDuring the early years of our modern computer era, very... Read More
The intuitive algorithm.Roger Penrose considered it impossible. Thinking could never... Read More
Microsoft Great Plains fits to majority of horizontals and retail... Read More
Pirated software is on the increase and now accounts for... Read More
Innovative Maintenance Systems (IMS) is one company that offers solutions... Read More
Microsoft Business Solutions Great Plains, Navision, Axapta, Solomon and CRM... Read More
I have always had a tendency to focus on the... Read More
If you would like to pick something from Microsoft, or... Read More
Great Plains Inventory Management (IV) module gives your business a... Read More
The term "document management" and "paperless office" is the subject... Read More
Software |