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 + " " + 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.

scheduled maid service Northbrook ..
In The News:

A third-party dental marketing agency's unsecured database exposed millions of patient profiles with personal information that could be exploited for identity theft and insurance fraud.
New York-based Aircela unveils refrigerator-size device that converts air and water into fossil-free gasoline, with initial deployments planned for 2025.
Your home address is easily accessible on people finder sites, putting you at risk for stalking and identity theft, but data removal services can help protect your personal information.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents
Robot combat evolves at Unitree's Iron Fist King event as G1 robots face off in China, featuring knockouts, precise strikes and agile machines that can perform side flips.
Take control of your digital privacy with actionable tips like Facebook privacy checkup, location tracking management and data removal services to protect your personal information.
Smart TVs and streaming devices manufactured in China are being compromised by BadBox 2.0 malware before users even power them on; infections have been detected in 222 countries.
The lightweight, 15-pound Tenniix tennis robot mimics pro playing styles like Nadal and Federer, using AI trained on 8,000 hours of professional tennis data.
Oak Ridge's uranium enrichment facility supports America's AI ambitions amid concerns that China's aggressive nuclear reactor construction could give it an edge in powering data centers.
Facebook scam ads now leverage AI and deepfakes to create convincing celebrity endorsements, targeting specific demographics with sophisticated schemes.
Apple unveils iOS 26, macOS 26 Tahoe and iPadOS 26 with translucent Liquid Glass design at WWDC 2025, featuring ChatGPT integration as competitors advance rapidly.
The Atom Touch prosthetic arm combines an AI neural interface with EMG sensors, allowing amputees to control individual fingers with precision at an affordable $25,000.
Aspen officials aim to have crews on the scene within five minutes — something they say would be nearly impossible without precise location data the AI technology gives.
Tech expert Kurt “CyberGuy" Knutsson says iPads are usually secure, but hackers can access them. Spot warning signs early to protect your data.
Tech expert Kurt Knutsson reveals how to easily move photos and videos off your iPhone or Android to securely protect your favorite moments.
The Social Security Administration is launching digital SSN access this summer. Tech expert Kurt “CyberGuy" Knutsson helps you learn how to use it and protect your identity.
Glide underwater with CudaJet and make the ocean your playground. Kurt “CyberGuy" Knutsson discusses the redesigned tech that might be your next big thrilling adventure.
Protect yourself from login alert scams with five security steps, including avoiding suspicious links, checking account activity and enabling two-factor authentication
Skip the usual Father's Day gifts with personalized ideas for tech enthusiasts, home brewers, pool owners, seniors, outdoor lovers and privacy-conscious dads.
DMV text scam alert: Fraudsters impersonating motor vehicle departments nationwide are sending threatening messages about unpaid tickets and tolls to steal your information.
Fox News' AI Newsletter brings you the latest on this rapidly evolving technology.
E-BAR, MIT's mobile robot, provides physical support for seniors with handlebars that follow from behind, helping prevent falls while maintaining dignity for aging adults.
AI is changing everything – now, we can even use it to generate video. I tried OpenAI's Sora and Google's Veo – here's how they measure up against each other.
Five simple phone setting tweaks that make your device work harder for you, from automatic text message deletion to scheduled focus modes.
Android users can save time with 10 simple automations, including automatic battery saver mode, location-based Wi-Fi settings and scheduled "Do Not Disturb" mode.

Spyware - The Internet Devil Of Our Times!

Spyware and Adware infest over 90 percent of computers in... Read More

Artificial Intelligence And Intuition

The intuitive algorithm.Roger Penrose considered it impossible. Thinking could never... Read More

OLAP, An Alternative Technology Over Spreadsheets

Are Spreadsheets Robbing your Enterprise of Competitive Advantage?'90% of "average"... Read More

Microsoft CRM Integration with Lotus Notes Domino: Messaging Connector ? Future Directions

IBM Lotus Notes Domino and Microsoft CRM (Client Relation Management)... Read More

Does Microsoft have any real competition?

Does Microsoft Have any Real Competition? Copyright (c) 2003 Gregory... Read More

ERP Consulting: Microsoft Great Plains Partner Future Directions

In the Clinton era the status quo was simple: you... Read More

Data Quality Best Practices for Salesforce.com

Executive SummaryAn effective plan for entering, cleaning and updating the... Read More

MultiNational Corporation ERP Implementation ? Microsoft Business Solutions Great Plains

If you look back to the history, you will see... Read More

Microsoft Great Plains: Annual Enhancement Program ? How To Be Re-Enrolled

Microsoft Business Solutions Great Plains is mid and even corporate... Read More

Why Stick With Email Clients Like Outlook?

Trying to figure out a stream in banning one email... Read More

Groupware and Version History: Collaboration Series #1

This article is the first of a series of articles... Read More

IBM Lotus Domino or Microsoft Exchange?

IBM Lotus Domino or Microsoft Exchange?The severe competition continues for... Read More

Introducing GRML

Creating a new markup language.Introduction.General Reuse Markup Langauge, or GRML,... Read More

Microsoft CRM Integration & Customization: SharePoint Document Gateway

MS CRM is very close to document workflow automation, including... Read More

What is Shareware?

Shareware is software that you can try before you buy;... Read More

5 Mac Security Tips You Can?t Live Without

So, you've bought a new Macintosh, and now you may... Read More

Online PowerPoint Presentation ? Convert PowerPoint to Flash

Although we don't know whether Microsoft ever envisioned such a... Read More

Cisco Certification: Introduction To ISDN, Part IV

In part III of this ISDN primer, we learned that... Read More

Crystal Reports - Microsoft SQL Server

Microsoft SQL Server is the leader for inexpensive and middle... Read More

Great Plains Custom Development: Dexterity, VBA, SQL, Crystal, eConnect ? Overview For Programmer

Microsoft Great Plains is main Microsoft Business Solutions accounting package... Read More

Preventive Maintenance Software Companies

Several software companies design programs for preventive maintenance. Most of... Read More

Make or Break Factors - When Considering Estimating Software

Make-or-Break Factors in Success and ProfitabilityFor quick printers, estimating can... Read More

Great Plains Dynamics/eEnterprise Upgrade ? Things to Consider and FAQ

If you have Great Plains Dynamics/eEnterprise (version 6.0 or earlier)... Read More

Microsoft Great Plains, Navision, Axapta ? Selection Considerations

During the years of our consulting practice, which comes back... Read More

Microsoft Great Plains: Data Conversion & Migration Scenarios ? Overview for Consultant

Microsoft Business Solutions Great Plains serves multiple industries in the... Read More

reliable maid service Highland Park ..