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.
elite cleaning services Mundelein ..DBxtra goes ASPGetting to the information hidden within corporate databases... Read More
What is Colossus?Colossus is software licensed to about twenty-five insurance... Read More
While Adobe is the most known maker of PDF tools,... Read More
Table of Contents1) Introduction 2) Related Work 3) Framework 4)... Read More
Microsoft CRM customization techniques are very diversified and based on... Read More
A wiki is an editable text-based website. But you don't... Read More
Microsoft CRM has built-in conversion tool, however you should probably... Read More
The most important benefit of XML is its simplicity. Though... Read More
Manufacturing in the USA is far away down from mid... Read More
Microsoft Business Solutions CRM is present several years on the... Read More
This article is the first of a series of articles... Read More
Shareware has been fighting the stigma of being misunderstood for... Read More
In linux, one of great commands for finding out information... Read More
When you visit department stores and see that majority of... Read More
Most people understand that the "hardware" part of their computer... Read More
When my daughter was getting into AOL instant messaging (AIM)... Read More
2005 ? Back to the Future.What does the future hold?... Read More
Costs of fleet maintenance software can vary widely. It is... Read More
Microsoft Business Solutions Great Plains is mid and even corporate... Read More
In order to meet regulatory and corporate compliance requirements reporting... Read More
Background: For many organizations like ours, the interim target of... Read More
Whether you have used Microsoft Word for years, have just... Read More
Microsoft Business Solutions Great Plains was purchased from Great Plains... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
Microsoft Business Solutions Great Plains serves multiple industries in the... Read More
Airbnb cleaning service Mundelein ..Adobe Photoshop is one of the world's leading graphics editing... Read More
There are certain pluses and minuses in both cases and... Read More
A LOT OF UNWANTED FILES.When you uninstall an item of... Read More
Microsoft Business Solutions ? Navision is an integrated solution for... Read More
Are Spreadsheets Robbing your Enterprise of Competitive Advantage?'90% of "average"... Read More
Best Software Act! is very popular CRM for small and... Read More
Does Microsoft Have any Real Competition? Copyright (c) 2003 Gregory... Read More
Whether you are a small consultancy firm, a medium sized... Read More
Background: For many organizations like ours, the interim target of... Read More
New post-recession era has new features, which didn't exist in... Read More
Assertion facility is added in J2SE 1.4. In order to... Read More
Software development is a risky business.Many software developers are barely... Read More
Former Great Plains Software Dynamics/eEnterprise, and currently Microsoft Business Solutions... Read More
Spyware and malware are large problems for Internet users today... Read More
As seeing large number of implementations ? in our case... Read More
The Windows Indexing Service provides you with the ability to... Read More
During the years of our consulting practice, which comes back... Read More
Great Plains Fixed Assets Management module is a robust tool... Read More
... Read More
Now that spyware is the single most dangerous threat to... Read More
Microsoft Business Solutions Navision serves both European and American megamarkets.... Read More
Microsoft Business Solutions Great Plains has several options to enable... Read More
Scrapbooks are very popular these days. I think that almost... Read More
1. Replace Dexterity cursor with SQL Stored Procedure Dexterity... Read More
This short paper will expand on two key reasons to... Read More
Software |