Removing Incoming Email in MS Exchange, C# Example - myoddPc

Computer Information - myOddPc

Removing Incoming Email in MS Exchange, C# Example

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 + "\n" + 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.adFailIfNotExists,ADODB.RecordOpenOptionsEnum.adOpenSource,"", "");rec.DeleteRecord(bstrURLItem, false);rec.Close();oCn.Close();rec = null;oCn = null;}catch (Exception ex) {log.Debug(ex.Message + "\n" + ex.StackTrace);} }Happy customizing! Boris MakushkinBoris 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.

Boris Makushkin

Sony PSP - Not Just For Games

Zen and the Art of Buying Computer Parts
The Ugly Face Of Technology
Wind Turbine Lights to Protect Birds
Robotic Manufacturing Lighting
Is that software really free?
Tips on Finding the Best CD Duplication Services
Making the Most of Digital Camera Memory Cards
Microsoft Dynamics GP & CRM in Transportation & Logistics
Computer Dos and Donts
Sony PSP - Not Just For Games

Microsoft RMS – Great Plains Integration – Overview For IT Specialist

Basic Tips and tricks for Windows XP
Buying the Perfect Computer – The FIRST Time
Dirty Little Computer Viruses and How To Protect Yourself
10 Secrets to a Healthy Computer and a Happier You
8 Simple Ways to Defend Against Evil Doers Both Online and Off
Microsoft CRM Programming Secrets – Tips For Developers
Microsoft Great Plains Integration with Legacy Systems – Overview For Developer
Microsoft RMS – Great Plains Integration – Overview For IT Specialist

Articles by the same author

Removing Incoming Email in MS Exchange, C# Example
Navision Attain C/ODBC Crystal Report – Customization Example
Navision Attain Database access via C/ODBC in ASP.

NET Application

Oracle Development: JDeveloper 10G – Java, J2EE, EJB, MVC, XML - Overview For Programmer
Microsoft CRM Customization – Programming Closed Email Activity
Microsoft CRM Integration & Customization: SharePoint Document Gateway

Disclaimer

Please note that this website is for information only. Whilst every care has been taken to provide accurate information you should always seek the advice of a professional before attempting any repairs or making any purchase(s).
You need to take special care to ensure that the information given applies your system.

Crystorama Chandelier
Compare Crystorama Chandeliers prices from 8 different stores.

Cheap Flights
Cheap flight information from uk destinations.
marker About Us | Site Map | Privacy Policy | Contact Us | ©2005-2006