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.
whole house cleaning Highland Park ..Microsoft Business Solutions Great Plains is very popular ERP/MRP applications... Read More
Preventive Maintenance (PM) is defined as scheduled work done on... Read More
MS CRM is very close to document workflow automation, including... Read More
When it comes to screenplay software each screenwriter needs to... Read More
Are Spreadsheets Robbing your Enterprise of Competitive Advantage?'90% of "average"... Read More
When you double-click a layer in the Layer Palette, you... Read More
We'll give you non formal view, based on our consulting... Read More
Great Plains Fixed Assets Management module is a robust tool... Read More
Is your PC is slow and wimpy? Then you need... Read More
Spyware, what it is and what it does. Basically, spyware... Read More
Just when you thought you were Web savvy, one more... Read More
Most people understand that the "hardware" part of their computer... Read More
ERP (Enterprise Resource Planning) Overview covers What is ERP, Brief... Read More
With many manufacturing shops heading over seas in favor of... Read More
Small can be beautiful! Working with Knoppix for the past... Read More
With the advent of 'Service Pack 2' for Windows XP... Read More
Crystal Reports is the most flexible tool on the market... Read More
Today's business world is fast-paced. No matter what it is... Read More
Although statistics often is blamed for various deadly sins --... Read More
Microsoft CRM is winning market share step-by-step from such the... Read More
It is now common thing when large corporation selects mid-market... Read More
If you are to buy a HelpDesk & Asset Management... Read More
Anti-virus software is used to find, remove or fix files... Read More
You have gotten those E_Mails buy software at deep discounts.... Read More
It would be easy to think, like most people apparently... Read More
pet-friendly home cleaners Glenview ..Microsoft Business Solutions CRM is now approaching the phase of... Read More
I suggest that you do not spend a lot of... Read More
It's all about turn times in the eMedia industry! The... Read More
Microsoft Great Plains could be tuned and setup to fit... Read More
Fundraising software lets you connect with donors in a way... Read More
You've finally created databases that you can actually use to... Read More
We'll give you non formal view, based on our consulting... Read More
Best Software Act! is very popular CRM for small and... Read More
You might think you don't need a firewall... Read More
Introduction: The creating of a computer program involves a number... Read More
Spyware, what it is and what it does. Basically, spyware... Read More
GroupwareEfforts are continually made to manage the unavoidable ad hoc... Read More
Does Microsoft care for WebmastersIt's always been a problem with... Read More
The intentions of this short tutorial are not to teach... Read More
In our small article we'll consider Microsoft Business Solutions Great... Read More
If you use Microsoft Outlook (or similar applications) for e-mailing,... Read More
Microsoft Business Solutions Great Plains has substantial market share among... Read More
A wiki is an editable text-based website. But you don't... Read More
ERP Consulting industry is on the way to serve clients... Read More
Although statistics often is blamed for various deadly sins --... Read More
Microsoft Business Solutions Great Plains serves multiple industries in the... Read More
This tutorial covers OLAP solutions used by Data warehouses and... Read More
If you have Microsoft Great Plains as main accounting and... Read More
The java programming language is becoming more and more popular... Read More
Beginning with Domino version R4 it has integration with the... Read More
Software |