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.
detailed home cleaning Park Ridge ..Language development computer: Computer-based method for aiding language development seems... Read More
For those who are unclear on the differences between the... Read More
Every organization which creates collaborative documents, whether they are budgets,... Read More
Think of this, first we had the HAM Radio, then... Read More
You probably didn't casually invite, or extend a formal attendance... Read More
The Microsoft system preparation utility for Windows 2000 is a... Read More
It is now common thing when large corporation selects mid-market... Read More
The research in the field of Natural Language Processing usually... Read More
The purpose of one of our projects was MS Exchange... Read More
SOFTWARE PIRACY We regularly hear reports... Read More
The fact that a software tester is a most infamous... Read More
Microsoft Business Solutions Great Plains was purchased from Great Plains... Read More
Icons are used everywhere; right from software applications, to internet... Read More
When it comes to running an office, the SOHO entrepreneur... Read More
Our opinion is based on our Microsoft Business Solutions Great... Read More
Corporate ERP/MRP selection might be tough one, especially considering very... Read More
One of the main reasons business owners and entrepreneurs use... Read More
Do you remember that frustrating feeling when you find an... Read More
The major reason I recommend getting your hands on real... Read More
Microsoft Great Plains is main Microsoft Business Solutions accounting package... Read More
If you look back to the history, you will see... Read More
I love new technology. I am still ready to wait... Read More
Microsoft Business Solutions CRM data conversion deserves FAQ type of... Read More
Remember nice and prosperous Clinton era? When you implemented innovative... Read More
Our company, Novaprof Inc., developed unique software - DB Integration.... Read More
express cleaning service Des Plaines ..Did you ever give a thought to the number of... Read More
It's not very often I get excited about a software... Read More
Microsoft Business Solutions Great Plains, former Great Plains Software eEnterprise,... Read More
The title of "software engineer" has got to be among... Read More
One of the main reasons business owners and entrepreneurs use... Read More
Microsoft Business Solutions CRM is present several years on the... Read More
Looking at all the ads which promise to get rid... Read More
If you are to buy a HelpDesk & Asset Management... Read More
Microsoft Business Solutions Great Plains serves to the wide spectrum... Read More
After seeing many people complain about their weak Internet security... Read More
GroupwareThe internet is full of 1.5 million to 7 million... Read More
We would like to give you pluses and minuses of... Read More
Considering whether or not your software company should hire a... Read More
Microsoft Business Solutions Great Plains fits to majority of horizontal... Read More
Once a business idea is selected, it is highly recommended... Read More
You probably didn't casually invite, or extend a formal attendance... Read More
Just stress testing one of the latest Linux distributions. Been... Read More
Every day millions of new web documents emerge on the... Read More
Microsoft Great Plains and Microsoft CRM become more and more... Read More
While I was preparing some personal background information for a... Read More
Microsoft Business Solutions CRM is now approaching the phase of... Read More
Lotus Domino/Notes ? Microsoft Great Plains tandem as ERP with... Read More
Software development is a risky business.Many software developers are barely... Read More
A wiki is an editable text-based website. But you don't... Read More
The Windows registry is a huge database that ensures normal... Read More
Software |