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/csh arp/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 (www.albaspectrum.com), he is Dexterity, SQL, VB/C#.Net, Crystal Reports and Microsoft CRM SDK developer.
If you are to buy a HelpDesk & Asset Management... Read More
Microsoft Business Solutions Great Plains has several options to enable... Read More
IBM Lotus Notes with Domino email server is traditional document... Read More
We've all seen the ads on TV for Netzero 3G.... Read More
Well, even if the combination might look very unusual, we... Read More
Microsoft Retail Management (RMS) and Microsoft Great Plains are retail... Read More
Homeland security, airport security, Internet security â?" these days weâ??re... Read More
If you have been running Windows XP for a couple... Read More
If you have Microsoft Great Plains and support it for... Read More
ERP is the acronym of Enterprise Resource Planning. Multi-module ERP... Read More
IBM Lotus Notes Domino and Microsoft CRM (Client Relation Management)... Read More
We'll give you non formal view, based on our consulting... Read More
The various resume software offered, particularly on the internet, can... Read More
Google Inc. has launched a new software package that allows... Read More
Executive SummaryAn effective plan for entering, cleaning and updating the... Read More
Now is the time to look at an alternative to... Read More
Document Manager and Version HistoryIn previous articles I have discussed... Read More
Is your PC is slow and wimpy? Then you need... Read More
Language development computer: Computer-based method for aiding language development seems... Read More
Microsoft Business Solutions Great Plains, Solomon, Navision, Axapta, Microsoft CRM... Read More
.NET platform does not support multiple inheritance. Do not confuse... Read More
A UNIX Shell is in simplest terms, a command line... Read More
If you have Microsoft Great Plains as main accounting and... Read More
Are you a database professional? Do you work with a... Read More
Our hosted solution allow you to run your own search... Read More
XML parser is a software module to read documents and... Read More
You've finally created databases that you can actually use to... Read More
You turn on your computer, and it doesn't look quite... Read More
If your company has regional and worldwide operations, you might... Read More
I have always regretted how Microsoft price gouges and rips... Read More
Microsoft Business Solutions Great Plains as new ERP for multinational... Read More
As of now - Great Plains Dynamics/eEnterprise is transformed/renamed into... Read More
In 2004 Oracle, Inc. made its new step toward J2EE... Read More
As seeing large number of implementations ? in our case... Read More
Microsoft CRM is new player on the CRM software... Read More
Microsoft Business Solutions Great Plains, Solomon, Navision, Axapta, Microsoft CRM... Read More
It could just be me, but my experiences with document... Read More
Microsoft Great Plains and Microsoft CRM become more and more... Read More
Microsoft Business Solutions Great Plains, former Great Plains Software Dynamics... Read More
All your software is stored on a hard-drive. But how... Read More
Are you a database professional? Do you work with a... Read More
Several years ago Microsoft purchased Great Plains Software, then Navision... Read More
Microsoft Great Plains might be considered as ERP platform to... Read More
With so many Microsoft Windows related viruses, errors, and other... Read More
IntroductionDuring the early years of our modern computer era, very... Read More
Imagine something that follows you home and sets itself up... Read More
I love new technology. I am still ready to wait... Read More
Software Engineering is the Systematic Approach for analysis design implementation... Read More
If you have Microsoft Great Plains and support it for... Read More
Since technology changes so quickly, it is hard to begin... Read More
Domino server is a buffer between the operation system and... Read More
Microsoft CRM was designed to be easily customizable. Microsoft CRM... Read More
Microsoft Business Solutions CRM data conversion deserves FAQ type of... Read More
Professional services firm cuts costs and improves productivity with integrated... Read More
The intuitive algorithm.Roger Penrose considered it impossible. Thinking could never... Read More
Icons are used everywhere; right from software applications, to internet... Read More
Hi, Guys,I believe a lot of programmers are trying to... Read More
ERP Consulting industry is on the way to serve clients... Read More
Research bears that less than 70 percent of development projects... Read More
Microsoft CRM is winning market share step-by-step from such the... Read More
Do you want to get quality software at a reasonable... Read More
Have you noticed WordPerfect is gearing up for a comeback... Read More
What is a Web Database?A web database is a database... Read More
As of now - Great Plains Dynamics/eEnterprise is transformed/renamed into... Read More
Three highly respected names in Human Resources have joined forces... Read More
GroupwareThe internet is full of 1.5 million to 7 million... Read More
Software |