gulliversfind.com gulliversfind.com gulliversfind.com
Site Home :> About Us :> Add Url :> Security & Privacy :> Terms & Conditions :> Add Article
Search:   
Add Url
 
 

Employment & Careers

 

Children & Teens

 

Software & Networking

 

Research & Science

 

Academics & Learning

 

Self Enhancement

 

Realty & Property

 

Business & Commerce

 

Issues & News

 

Culture & Art

 

Indoor Games

 

Automobile & Automotive

 

Lifestyle & Fashion

 

Travel & Accommodation

 

Policies & Law

 

Music & Entertainment

 

Shopping Online

 

Healthcare & Treatment

 

Health & Therapy

 

People & Society

 

Sports & Adventure

 

Home Family & Garden

 

Food & Recipe

 

Banking & Finance


 

Site Home › Software & Networking › Computer Software
 

Removing Incoming Email in MS Exchange, C# Example

 
Author: Boris Makushkin

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 users 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 Makushkin

Author Bio:
Boris Makushkin is a renowned writer. Boris likes to compose articles about this field.
You can search for this article using: Removing Incoming Email in MS Exchange, C# Example, Software & Networking, Computer Software
 
 
 

Related Articles

 
Use Free PR to Build Web Site Traffic
 
The Future Arrives As Ultra-Wideband (UWB) Becomes Reality
 
Did Someone Knock on Your Door Today to Give You a Multimillion Dollar Business?
 
Online Marketing: High-Impact Marketing Strategies
 
Writing Quality Articles to Promote Your Business
 
The Differences Between Software Development and Software Engineering
 
The Value of Search Engine Marketing
 
Does Your Web Site Facilitate The New Breed Of Layman Users?
 
Anti-virus Software - Important Features You Should Look For When Choosing Anti-virus Software
 
Ebusiness Development
 
 
 
Site Home :> Security & Privacy :> Terms & Conditions  
Copyright © 2008 www.gulliversfind.com