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.

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

Tech expert Kurt “CyberGuy" Knutsson says a malware app called SpyLend is posing as a financial tool, hitting 100,000-plus downloads.
Tech expert Kurt “CyberGuy" Knutsson says Clone Robotics’ Protoclone mimics humans with 1,000 muscles – too human for comfort.
Tech expert Kurt “CyberGuy" Knutsson urges you to use Apple’s App Privacy Report to see what your apps are really up to.
Tech expert Kurt “CyberGuy" Knutsson talks about how to smoothly transfer your data from an old laptop to a new one using cloud storage or external drives.
Kurt the CyberGuy offers tips to safeguard your personal information as scammers become more sophisticated with scam texts and other methods.
WeRide's unmanned electric delivery van, the Robovan W5, has 194 cubic feet of cargo space and can carry payloads up to about 2,205 pounds
Kurt the CyberGuy recommends deleting 16 browser extensions immediately in response to a report saying more than 3.2 million web users were affected by a security breach.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
A robotics firm in China claims a robot has performed the world's first humanoid robot front flip, which is significantly more difficult than a backflip.
A digital ID may be even more secure than a physical ID. Storing your driver's license in your Apple Wallet is an ideal solution for commuters.
A cybersecurity firm has shed some light on just how common tax scams have become. Kurt the CyberGuy offers his advice for how to protect your refund.
Lifesize Plans offers immersive walk-throughs that allow customers the opportunity to tour a home's design before construction actually begins.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
A man invested $4 million in bitcoin and lost it all with a single click when he was targeted by a vishing scam, which uses phone calls to trick people.
Expandable's Touchdown is a designer trailer that promises a luxury off-grid living experience and unfolds into a home in about 15 minutes.
Major employee screening company data breach affects 3.3 million people. Tech expert Kurt “CyberGuy" Knutsson explains what happened and gives five ways to protect your data.
Kurt “CyberGuy" Knutsson reveals mind-blowing tech that gives you sunlight on demand.
New malware "FrigidStealer" targets Mac computers. Tech expert Kurt “CyberGuy" Knutsson offers four ways to stay safe from infostealer malware.
Kurt “CyberGuy" Knutsson talks about how lab-grown muscles power a biohybrid hand for scalable prosthetics and research.
Reports of task scams have significantly risen in the past four years, according to the Federal Trade Commission. Kurt the CyberGuy offers some red flags.
iPhones have a hidden folder that eats up storage without you knowing it. Kurt the CyberGuy offers some tricks to free up storage on your device.
A recent ransomeware attack targeted Zacks, an American investment firm, and a cybercriminal claimed to have stolen records for millions of customers.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
Researchers unveiled a new soft prosthetic hand that combines the natural coordination patterns of our fingers with the decoding of motoneuron activity in the spinal column.
Accidentally deleting a text message on your iPhone or iPad is not a problem if you still need the message. Apple has a built-in way to recover it.

A Simple Computer Software Definition

What is Software?Software is a set of instruction written to... Read More

Instant Messaging is a Sweet Way to Communicate

MSN messenger is a pretty cool invention. I mean I'm... Read More

Top Questions to Ask Before Buying a Help Desk & Asset Management Software

#5 All your hardware components like Printers, PCs etc come... Read More

Assertion in Java

Assertion facility is added in J2SE 1.4. In order to... 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

Choose your Java Wisely

Java has come along a long way. Many would agree... Read More

Five Reasons for Using an O/R Mapping Tool

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

Adware and Spyware

What is 'adware'?Adware is basically software or scripts that are... Read More

How to Get The Best Accounting Software For Your Small Business

Buying accounting software is a major investment. It's an important... Read More

Does Microsoft have any real competition?

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

Microsoft Great Plains - Typical Problems And Fixes ? Overview For IT Administrators

How to delete the user? This is the first problem... Read More

Great Plains Bill of Materials Setup & Customization for Process Manufacturing ? Overview

Microsoft Great Plains has full-featured Manufacturing suite of modules: Capacity... Read More

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

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

Monitoring Software Can be Used for Spying as Well

We all already got used to computer monitoring both at... Read More

A Time-Saving Programming Tactic that Doesn?t Work

Let's say that you have a software project that's under... Read More

DVD Burning Tips

CD and DVD replication is a process that works by... Read More

Why do Manufacturers Invest in Business Management Software?

With many manufacturing shops heading over seas in favor of... Read More

Benefits of Shareware

Shareware has been fighting the stigma of being misunderstood for... 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

Review on QuarkXpress 6.0

After almost two decades of existence, Quark has become the... Read More

Accessing XML Using Java Technologies

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

Corporate ERP: Standard vs. Rich functionality ? Microsoft Great Plains

Traditionally we were considering functionally rich systems, such as SAP,... Read More

Screenshots Vista Windows

Features Additionally, Vista will include many other new features.Aero Vista... Read More

Causes of ERP Failures

ERP is the acronym of Enterprise Resource Planning. Multi-module ERP... Read More

Removing Incoming Email in MS Exchange, C# Example

The purpose of one of our projects was MS Exchange... Read More

Mokena Chicago limo O'Hare ..