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.

Wood Dale Chicago prom limo .. Lockport Chicago limo O’Hare
In The News:

Fueled by artificial intelligence, CyberDog the robotic dog is designed specifically locate fire ant nests, which are endangering ecosystems.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents
Internet browsers are useful, but they can be dangerous. Clicking on malicious links can direct you to dangerous websites that steal information or infect your device.
Apple's latest iOS update introduces advanced artificial intelligence capabilities, which may be capturing and analyzing sensitive information.
Breach site confirmed 56,904,909 Hot Topic users' data leaked online. Tech expert Kurt “CyberGuy" Knutsson says the company's silence makes matters even worse.
Tech expert Kurt “CyberGuy" Knutsson discusses how an innovative Easy-Way kit turns standard strollers electric, simplifying navigation for parents.
Tech expert Kurt “CyberGuy" Knutsson talks about T-Mobile being hacked in broad cyberattack on global phone and internet companies.
Tech expert Kurt “CyberGuy" Knutsson shows you how to add, customize and manage widgets for quick access to apps and info from your iPhone home screen.
Wrong Google searches can not only compromise your device and personal data. They can also bring law enforcement to your doorstep. Hackers are targeting Google searches.
China's Shanghai Kepler Robotics has developed a new humanoid robot that can carry up to 35 pounds per hand for commercial applications across various industries
Checking your hearing has gotten easier with the new hearing test feature in AirPods Pro 2. You can take reliable hearing tests using your iPhone or iPad.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
Kurt "CyberGuy" Knutsson explains how a VPN — virtual private network — works and how running it can slow down the operation of your device.
The WalkON Suit F1, an exoskeleton developed to help people with disabilities, can actually walk over to a person in a wheelchair, solving a major problem.
ClickFix, a new scam targeting computer users, is on the rise in the U.S. The scam prompts its targets to click on a link to fix a problem.
Skydweller is the world's largest unmanned solar-powered aircraft that can stay airborne for weeks, and even months, without refueling.
The U.S. government said it is investigating after People's Republic of China hackers targeted commercial telecommunications service providers in the U.S.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
Scammers are using increasingly sophisticated ways to lure unsuspecting victims, and some are impersonating an email help desk or support team.
You can unsend or edit your iMessages with the latest iOS updates. Kurt the CyberGuy explains how you can save yourself some potential embarrassment.
Kurt “CyberGuy" Knutsson says there’s been a rise in cybercriminal services using hacked police and government emails to send subpoenas and data requests to U.S. companies.
Kurt “CyberGuy" Knutsson discusses how Axiom Space and luxury designer Prada are collaborating on NASA's Artemis III spacesuit design.
Voice assistants may cause confusion across devices. Tech expert Kurt “CyberGuy" Knutsson offers some solutions to fix it.
Shameless scammers trick veterans into giving personal info or cash. Tech expert Kurt “CyberGuy" Knutsson explores five common scams.

Lotus Notes Domino and Web: Application Development ? Tips for Programmers

Beginning with Domino version R4 it has integration with the... Read More

Anti-Virus Software

Anti-virus software is used to find, remove or fix files... Read More

Best Practices In Choosing Network Monitoring Software

Blue Cross and Blue Shield of Hawaii (HMSA) found itself... Read More

Fleet Maintenance Software Reviews

Innovative Maintenance Systems (IMS) is one company that offers solutions... Read More

3 Reasons Why Medical Billing Software is Leading the Way

Since technology changes so quickly, it is hard to begin... Read More

Cross-Platform Custom Software Development & Integration ? IT Strategy for Large Corporation

Microsoft Business Solutions products: Great Plains, MS CRM, Navision, Axapta,... Read More

Linux Secrets

The first thing that you will notice about Linux Red... Read More

An Introduction to .NET Framework

.Net Framework is a platform or development environment to seamlessly... Read More

5 Easy File Management Tips in Microsoft Word

How many steps does it take you to locate and... Read More

Microsoft CRM Integration & Customization: SharePoint Document Gateway

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

OEComplete ? A Personal Information Manager

OEComplete is a utility for managing the personal information of... Read More

Great Plains Dexterity Programming ? Overview For Developer

Looks like Microsoft Great Plains becomes more and more popular,... Read More

Computer Based Language Development and Spell-checking

Language development computer: Computer-based method for aiding language development seems... Read More

Microsoft Great Plains Payroll Module Customization Scenarios

It is now common thing when large corporation selects mid-market... Read More

What is Software Piracy?

There are several kinds of software piracy. The bottom line... Read More

Microsoft Great Plains implementation: Restaurants Supply Chain Management Example

Microsoft Great Plains serves majority of US based horizontal and... Read More

Microsoft Great Plains: Government & Non-Profit Organization ? Workflow Implementation

Usually workflow & messaging is realized in CRM and then... Read More

Five Reasons for Using an O/R Mapping Tool

So, why should you use any O/R mapping tool? I... Read More

Protect Your Most Vital Business Asset with Security Software

Homeland security, airport security, Internet security ??" these days we???re... Read More

Software Development in 2005 - Back to the Future

2005 ? Back to the Future.What does the future hold?... 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

Microsoft Business Solutions Products Selection: ERP, CRM, Retail Management

Let's first look at your ERP system selection (without Retail... Read More

Software Engineering: An Introduction

Software Engineering is the Systematic Approach for analysis design implementation... Read More

Helping Newbies Understand Professional Software

The Windows registry is a huge database that ensures normal... Read More

Quick Summary of Basic and Common Linux Commands

There are many commands that are used in linux on... Read More

Antigo wedding limo ..