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.
cleaning service near Bannockburn ..Make-or-Break Factors in Success and ProfitabilityFor quick printers, estimating can... Read More
Microsoft Business Solutions is now in process of creating so... Read More
If you company is small or mid-size special products or... Read More
When you need a phone number, you do a quick... Read More
Are you lost in the mess of documents that get... Read More
While several preventive maintenance software manufacturers offer free trials for... Read More
Microsoft Great Plains serves majority of US based horizontal and... Read More
Is Photoshop CS2 worth the upgrade? You bet it is!... Read More
Handling character strings in Java is supported through two final... Read More
Microsoft Retail Management (RMS) and Microsoft Great Plains are retail... Read More
Microsoft Business Solutions Great Plains was purchased from Great Plains... Read More
I suggest that you do not spend a lot of... Read More
What is Interactive Mapping?Interactive mapping is a visual display medium... Read More
Ok... Where to start?Well, I guess I will start at... Read More
Costs of fleet maintenance software can vary widely. It is... Read More
Remember nice and prosperous Clinton era? When you implemented innovative... Read More
One day, you suddenly realize that your computer started to... Read More
In 2004 Oracle, Inc. made its new step toward J2EE... Read More
Microsoft Business Solutions Great Plains has several options to enable... Read More
Microsoft Great Plains, designed back in 1990th as database transferable... Read More
Former Great Plains Software Dynamics/eEnterprise, and currently Microsoft Business Solutions... Read More
We will base our prognosis on our Microsoft Business Solutions... Read More
Microsoft Great Plains as ERP and Microsoft CRM as... Read More
Mapping Software Improves Data VisualizationFrom the outset, it is important... Read More
Having from five to ten and more favorite screensavers is... Read More
pet-friendly home cleaners Mundelein ..According to a survey conducted by InfoTrends/CAP Ventures entitled "Content-Centric... Read More
Microsoft Business Solutions Great Plains serves to the wide spectrum... Read More
Microsoft Great Plains is main Microsoft Business Solutions accounting package... Read More
Current Microsoft Business Solutions Great Plains has more that 10... Read More
Microsoft Great Plains as ERP and Microsoft CRM as... Read More
When you visit department stores and see that majority of... Read More
This article is the third of a series of articles... Read More
One day, you suddenly realize that your computer started to... Read More
Spyware and Adware infest over 90 percent of computers in... Read More
Before September 1995, Microsoft Windows was an MS-DOS program. DOS... Read More
Microsoft Great Plains ? ERM from Microsoft Business Solutions and... Read More
SAP Inc., a global leader in client/server enterprise application software... Read More
Combining Microsoft Business Solutions Great Plains ERP with non-Microsoft Business... Read More
Great Plains Fixed Assets Management module is a robust tool... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
Microsoft bought Navision, Denmark based software development company, along with... Read More
Viruses and spyware usually show up on your computer one... Read More
Just the thought of a duel-boot scares many people away,... Read More
Before being able to choose a secure Internet communication system,... Read More
Microsoft Great Plains may be recommended for international freight forwarding... Read More
This short paper will expand on two key reasons to... Read More
Case study: A secretary using Corel WordPerfect 7 is often... Read More
We will base our prognosis on our Microsoft Business Solutions... Read More
Customer Relationship Management (CRM) is a strategy and processes used... Read More
People often ask me: What image file formats will Photoshop... Read More
Software |