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.
green cleaning service Glencoe ..Microsoft Business Solutions Small Business Manager is scaled down Great... Read More
Every day millions of new web documents emerge on the... Read More
Great Plains Purchase Order Processing (POP) module makes up one-third... Read More
With so many Microsoft Windows related viruses, errors, and other... Read More
Microsoft Business Solutions is emerging as very attractive vendor for... Read More
Just the thought of a duel-boot scares many people away,... Read More
Small can be beautiful! Working with Knoppix for the past... Read More
No matter how much you enjoy your favorite screensavers, sometimes... Read More
Costs of fleet maintenance software can vary widely. It is... Read More
Configuring PPP PAP AuthenticationNow we know how the ISDN link... Read More
Just stress testing one of the latest Linux distributions. Been... Read More
Are you a database professional? Do you work with a... Read More
Remember nice and prosperous Clinton era? When you implemented innovative... Read More
If you have Microsoft Great Plains and support it... Read More
SOFTWARE PIRACY We regularly hear reports... Read More
I like my software simple. If it's too complex or... Read More
The purpose of one of our projects was MS Exchange... Read More
Logistics automation is often considered as barcoding extension to Sales... Read More
Microsoft Business Solutions Small Business Manager is Great Plains Dexterity... Read More
The most important things you can do for your computer... Read More
If you have Microsoft Great Plains as main accounting and... Read More
If you would like to pick something from Microsoft, or... Read More
Viruses and spyware usually show up on your computer one... Read More
Microsoft Great Plains is main mid-market application from Microsoft Business... Read More
Table of Contents1) Introduction 2) Related Work 3) Framework 4)... Read More
house cleaning company Bannockburn ..Microsoft Business Solutions Great Plains, former Great Plains Software Dynamics... Read More
Running Applications in Compatibility Mode With Windows XP, you can... Read More
Well, even if the combination might look very unusual, we... Read More
Navision Software was purchased by Microsoft and now it is... Read More
Anyone who has ever used Microsoft Word knows that it... Read More
Did you ever give a thought to the number of... Read More
Heard about the Quark "killer"?Adobe InDesign CS2. Will it really... Read More
Customer Relationship Management, abbreviated "CRM," is the term for a... Read More
In the early days of the personal computer, we're talking... Read More
This article is for advanced Microsoft CRM SDK C# developers.... Read More
Microsoft Business Solutions CRM is web-based CRM application, deploying all... Read More
Microsoft bought Navision, Denmark based software development company, along with... Read More
Just the thought of a duel-boot scares many people away,... Read More
So, you've bought a new Macintosh, and now you may... Read More
DBxtra goes ASPGetting to the information hidden within corporate databases... Read More
Lotus Domino/Notes ? Microsoft Great Plains tandem as ERP with... Read More
Follow the steps below to quickly design, generate, and deploy... Read More
Microsoft Word is one of the most popular office applications... Read More
One day, you suddenly realize that your computer started to... Read More
A wiki is an editable text-based website. But you don't... Read More
Have you ever noticed that when you look at your... Read More
The intentions of this short tutorial are not to teach... Read More
How do you run a program on a remote server... Read More
... Read More
Whether you are an experienced web programmer or a complete... Read More
Software |