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.
Willow Springs limo O'Hare .. Lockport Chicago limo O’HareFormer Great Plains Software Dynamics/eEnterprise, and currently Microsoft Business Solutions... Read More
Looks like Microsoft Great Plains becomes more and more... Read More
Pirated software is on the increase and now accounts for... Read More
The most important things you can do for your computer... Read More
Software development is a risky business.Many software developers are barely... Read More
Mapping Software Improves Data VisualizationFrom the outset, it is important... Read More
The purpose of one of our projects was MS Exchange... Read More
If you have Great Plains Dynamics/eEnterprise (version 6.0 or earlier)... Read More
Are you a database professional? Do you work with a... Read More
Microsoft Great Plains has substantial mid-market share in the USA... Read More
Microsoft Business Solutions ? Navision is an integrated solution for... Read More
Make-or-Break Factors in Success and ProfitabilityFor quick printers, estimating can... Read More
If you are in a business that passes documents around... Read More
eStore Advantage allows front-office applications to communicate with back-office business... Read More
Microsoft Business Solutions products: Great Plains, MS CRM, Navision, Axapta,... Read More
I started using PIP (Picture It Publishing) Platinum 2002 right... Read More
Music downloads are off the charts! We're listening to digital... Read More
All of us know that Microsoft bought former Great Plains... Read More
We live in a post-industrial age where information is the... Read More
Whether you are a small consultancy firm, a medium sized... Read More
In the Clinton era the status quo was simple: you... Read More
Just imagine: you are walking, say, towards your car, and... Read More
Adware is a type of Spyware program that displays some... Read More
If someone entered your home, uninvited and installed numerous cameras... Read More
The Windows Indexing Service provides you with the ability to... Read More
group transportation logistics management Highland ..Sometimes your PC will start acting strange for no apparent... Read More
We've all seen the ads on TV for Netzero 3G.... Read More
I have always had a tendency to focus on the... Read More
Microsoft Retail Management (RMS) and Microsoft Great Plains are retail... Read More
Beginning with Domino version R4 it has integration with the... Read More
User interfaces and accessibility are some of the most important... Read More
What is RAID RECOVERY?RAID stands for Redundant Array of Inexpensive... Read More
In today's business world it's all but impossible to escape... Read More
Microsoft Business Solutions Great Plains version 8.5, 8.0, 7.5, Great... Read More
You've finally created databases that you can actually use to... Read More
It is possible that if one avoided all sources of... Read More
There is many things more frustrating than surfing a website... Read More
No matter how much you enjoy your favorite screensavers, sometimes... Read More
Microsoft Business Solutions Great Plains is Dexterity-written application and currently... Read More
The COSMIC FP (function point) software quality metric, is no... Read More
This article is for advanced Microsoft CRM SDK C# developers.... Read More
Words we choose to describe things and phenomena often show... Read More
Homeland security, airport security, Internet security ??" these days we???re... Read More
Introduction: The creating of a computer program involves a number... Read More
Microsoft Great Plains might be considered as ERP platform to... Read More
Stealing company information used to be the specialty of spies... Read More
Not every software testing project can or should be automated.... Read More
Several years ago Microsoft purchased Great Plains Software, then Navision... Read More
Spyware, what it is and what it does. Basically, spyware... Read More
What is 'adware'?Adware is basically software or scripts that are... Read More
Software |