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.

elite cleaning services Mundelein ..
In The News:

Scammers are flooding inboxes with fake tracking alerts that mimic real carriers, exploiting the holiday rush to steal logins and personal data.
The Fox News AI Newsletter brings you the latest news on AI technology advancements and the challenges and opportunities AI presents now and for the future.
Texas family reunites with missing 11-year-old cat Grayson after 103 days using Petco Love Lost's AI photo matching technology and community help.
Tired of AI customer service loops? These insider tricks help you escape "frustration AI" and get real human help when you need it most for urgent issues.
Unlock richer audio from your streaming apps with simple tweaks to volume normalization, equalizer settings, and quality preferences for cleaner sound.
Scammers are sending fake Facebook settlement payout emails that mimic legitimate notices from the privacy settlement administrator to deceive users.
Holiday shopping scams surge as fake refund emails target distracted consumers during Black Friday and holiday seasons, costing Americans billions annually.
The AI-powered IRMO M1 exoskeleton features four modes, including turbo, eco, training and rest for hiking, running, cycling and sports with eight-hour battery life.
OpenAI announced upgrades for its ChatGPT Images platform on Tuesday, saying the program can now make more precise edits and produce images more quickly.
Chrome for Android now turns web articles into AI-powered podcast conversations. Get hands-free browsing with Google Gemini's natural audio summaries.
LastPass faces $1.6 million fine from U.K. regulators after 2022 data breach exposed 1.6 million users. Password manager failed proper security controls.
Petco disclosed a data breach exposing customer Social Security numbers, financial account details, and driver's license information due to a software error.
Baseball teams can now analyze complete swing mechanics in normal training environments using Theia's markerless AI system that processes standard high-speed footage.
Smart home hacking fears overblown? Expert reveals real cybersecurity risks and simple protection tips to keep your connected devices safe from hackers.
MIT develops needle-free glucose monitor using light technology. Revolutionary device could replace painful finger pricks for diabetes management.
The ClickFix campaign disguises malware as legitimate Windows updates, using steganography to hide shellcode in PNG files and bypass security detection systems.
Researchers from Osaka Metropolitan University designed a 21-foot dome that combines aquaculture and hydroponics to create a self-sustaining urban food system.
The Fox News AI Newsletter gives readers the latest AI technology advancements, covering the challenges and opportunities AI presents.
ChatGPT data breach exposes personal info of users through partner Mixpanel. OpenAI confirms names, emails compromised in security incident.
Android rolls out Emergency Live Video for 911 calls, letting dispatchers see real-time scenes during emergencies. Great for holiday travel safety.
Malicious Chrome and Edge extensions collected browsing history, keystrokes and personal data from millions of users before Google and Microsoft removed them.
Google's new Call Reason feature lets Android users mark calls as urgent before dialing, displaying an urgent label to recipients using Phone by Google app.
Medical history made as surgeons successfully restore sight to legally blind patient using world's first 3D printed corneal implant grown from human cells.
Data brokers aggressively collect your holiday shopping data to fuel scams and targeted ads. Learn how to delete your digital profile before 2025 starts.
Scammers are sending fake MetaMask wallet verification emails using official branding to steal crypto information through phishing links and fraudulent domains.

Create ASP in Minutes

DBxtra goes ASPGetting to the information hidden within corporate databases... Read More

The Truth about Colossus: Are You Just A Magnetic Image?

What is Colossus?Colossus is software licensed to about twenty-five insurance... Read More

Dont Choose Adobe When Working With PDF

While Adobe is the most known maker of PDF tools,... Read More

CROOK: A Methodology for the Refinement of Forward-Error Correction

Table of Contents1) Introduction 2) Related Work 3) Framework 4)... Read More

Microsoft CRM Customization

Microsoft CRM customization techniques are very diversified and based on... Read More

A Simple Guide To Wikis

A wiki is an editable text-based website. But you don't... Read More

Microsoft CRM Data Import FAQ

Microsoft CRM has built-in conversion tool, however you should probably... Read More

Accessing XML Using Java Technologies

The most important benefit of XML is its simplicity. Though... Read More

Manufacturing Outsourcing: Microsoft Great Plains Implementation, Customization & Reporting

Manufacturing in the USA is far away down from mid... Read More

Microsoft CRM in Latin America: Implementation, Customization, Support ? Overview for Consultant

Microsoft Business Solutions CRM is present several years on the... Read More

Groupware and Version History: Collaboration Series #1

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

Benefits of Shareware

Shareware has been fighting the stigma of being misunderstood for... Read More

netstat - Linux Command to Display Networking Information

In linux, one of great commands for finding out information... Read More

Microsoft Great Plains: Offshore Customization & Development ? Overview for Consultant

When you visit department stores and see that majority of... Read More

Device Driver Basics

Most people understand that the "hardware" part of their computer... Read More

Software Upgrades Arent Always the Best Move

When my daughter was getting into AOL instant messaging (AIM)... Read More

Software Development in 2005 - Back to the Future

2005 ? Back to the Future.What does the future hold?... Read More

Where to Find Free Fleet Maintenance Software

Costs of fleet maintenance software can vary widely. It is... 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

Secure File Transfer Using SSH Plus Additional Audit & Automation - FSA Reporting

In order to meet regulatory and corporate compliance requirements reporting... Read More

Software Process Improvement -A Successful Journey

Background: For many organizations like ours, the interim target of... Read More

5 Time-Saving Tips in Microsoft Word

Whether you have used Microsoft Word for years, have just... Read More

Microsoft Great Plains international implementation ? USA / Mexico ? overview for consultant

Microsoft Business Solutions Great Plains was purchased from Great Plains... Read More

Microsoft Great Plains Middle East - Arabic Language Support

Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More

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

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

Airbnb cleaning service Mundelein ..