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.
top rated cleaning service Lake Forest ..A few months back I really got sick of my... Read More
Microsoft Business Solutions Great Plains has I'd say end user... Read More
In the early days of the personal computer, we're talking... Read More
If you are to buy a HelpDesk & Asset Management... Read More
The intentions of this short tutorial are not to teach... Read More
ERP Consulting industry is on the way to serve clients... Read More
TCO (Total Cost Ownership) is the buzzword in... Read More
With the advent of 'Service Pack 2' for Windows XP... Read More
In order to meet regulatory and corporate compliance requirements reporting... Read More
Lotus Notes Domino is very efficient in electronic document workflow... Read More
SyncUp, a file synchronizer is designed to assist the home... Read More
Before September of 1995, Microsoft ignored the Internet because their... Read More
Almost all new and major brand of PCs come with... Read More
The research in the field of Natural Language Processing usually... Read More
What is Tripwire?Tripwire is a form intrusion detection system (IDS)... Read More
Microsoft Great Plains ? ERM from Microsoft Business Solutions and... Read More
Stop the Runaway MouseWhat's the "runaway mouse?" You've seen it...you... Read More
In part III of this ISDN primer, we learned that... Read More
The Internet is reshaping every form of communications medium, and... Read More
One day, you suddenly realize that your computer started to... Read More
Microsoft Business Solutions Great Plains serves multiple industries in the... Read More
Microsoft Business Solutions offers several ERP applications: Great Plains, Navision,... Read More
Microsoft Business Solutions Great Plains might be considered as ERP... Read More
The cornerstone of successful automated office systems is the ability... Read More
If you look back to the history, you will see... Read More
insured cleaning company Morton Grove ..I started using PIP (Picture It Publishing) Platinum 2002 right... Read More
Remember back in the days where screensavers were the coolest... Read More
Microsoft Business Solutions Great Plains is very good fit for... Read More
Microsoft CRM customization techniques are very diversified and based on... Read More
C/SIDE (Client/Server Integrated Development Environment) - The core of... Read More
If you're online using a dialup Internet connection, you'll probably... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
Microsoft Business Solutions Great Plains serves to the wide spectrum... Read More
Customer Relationship Management or CRM is a combination of enterprise... Read More
Spyware and malware are large problems for Internet users today... Read More
For those who are unclear on the differences between the... Read More
Microsoft Great Plains could be tuned and setup to fit... Read More
Microsoft Great Plains is becoming more and more popular and... Read More
Stealing company information used to be the specialty of spies... Read More
Designing without tables by using CSS layouts is fast becoming... Read More
Microsoft Business Solutions Great Plains might be considered as ERP... Read More
Costs of fleet maintenance software can vary widely. It is... Read More
MSN messenger is a pretty cool invention. I mean I'm... Read More
This article is the third of a series of articles... Read More
Microsoft Great Plains and Microsoft CRM become more and more... Read More
DBxtra is a powerful query and reporting tool that hides... Read More
Sales are all about leverage, because there is only so... Read More
Professional services firm cuts costs and improves productivity with integrated... Read More
Our company, Novaprof Inc., developed unique software - DB Integration.... Read More
When you own a small business, time is money. And... Read More
Software |