ArticlesReader.com Menu
Newest Articles
Most Viewed Articles
ArticlesReader.com RSS
Submit Article
Login
Signup
Search the articles

Articles Main Categories
Advice
Animals
Automobiles
Business
Career
Communications
Computer Programming
Computers
Entertainment
Environment
Family
Fashion
Finance
Food
Health & Medical
Home & Garden
Humor
Internet Business
Internet Marketing
Legal
Leisure & Recreation
Marketing
Other
Politics
Reference & Education
Religion
Self Improvement
Sports
Technology & Science
Travel
Writing
Subscribe
Receive alert message from us when new articles submitted to our site for free.

Enter your name

Enter your email

Syndicate

















Related Products
Home::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 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 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.

Spam emails More free articles

Related articles


  1. Scrap Booking Online: Word Perfect or Corel Graphics Suite?
  2. Great Plains Dexterity Customization Options – Overview For Developers
  3. Microsoft Great Plains Security Setup - Overview For Consultant
  4. Microsoft Great Plains Implementation: Collection Management – Overview For Consultant
  5. Best Spyware Removers
  6. Monitoring Software Can be Used for Spying as Well
  7. Beware of Spyware
  8. Microsoft CRM Integration & Customization: SharePoint Document Gateway
  9. Adware, What Is It?
  10. Microsoft CRM Modification – Overview for IT Specialist
  11. Reporting Tools for Microsoft Great Plains – Overview For Developers
  12. Microsoft Great Plains Upgrade – Things to Consider and FAQ
  13. Great Plains Dexterity History and Programming Overview
  14. Microsoft Great Plains on Ctree or Pervasive SQL – What to Do – Tips for IT Manager
  15. Microsoft Business Solutions VAR/Partner Selection – Overview for IT Director/Manager/Controller
  16. Great Plains Accounting Migration to Microsoft Great Plains - Overview for IT Specialist
  17. Microsoft Great Plains Data Conversion – Overview For Developer
  18. Great Plains Dynamics/eEnterprise Upgrade – Things to Consider and FAQ
  19. Crystal Reports - Geterogeneus databases: SQL Server, Oracle, Unidata, Btrieve – Tips For Developer
  20. Great Plains Dexterity Programming – Overview For Developer
  21. Great Plains Custom Development: Dexterity, VBA, SQL, Crystal, eConnect – Overview For Programmer
  22. How To Create A Data Capture Procedure Checklist For Your Small Business CRM Software
  23. Chinese Input - Step by Step Instruction on How to Input Chinese Characters in English Windows XP
  24. Microsoft Great Plains - Payroll & HR Inexpensive Solution? Not Any More
  25. 20 Extra Hours Per Week: What Would You Do?
More related feeds

Warning: Invalid argument supplied for foreach() in /home/alamoart/public_html/articlesreader.com/feeds.php on line 13
 

 

© 2007 articlesreader.com - All Rights Reserved