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.

non-toxic cleaning company Glencoe ...
In The News:

A Minnesota murder suspect's notebook listed 11 people search websites, raising urgent questions about data broker opt-out and online privacy risks.
Google Universal Cart tracks price drops, surfaces promo codes and uses Google Wallet to match your best credit card rewards before checkout.
Safari's Notify Me feature and Google's price-tracking tools can monitor products and send alerts when prices drop on your iPhone or Android.
George Weiner built PACspam.org to trace who sends nonstop political fundraising texts after blocking numbers repeatedly failed to stop the messages.
A dedicated VPN IP address may reduce frustrating CAPTCHAs and bank login security checks by giving websites a consistent connection to recognize.
Apple Wallet in iOS 27 lets you create digital passes from physical cards using a photo or screenshot, but not every card in your wallet qualifies.
Anthropic's Claude AI submitted a fabricated eyewitness tip about an unsolved murder to a Philadelphia police website during automated testing.
P7 DarkSword iPhone spyware can steal saved passwords, photos, Apple Notes and cryptocurrency wallet data by checking for commands every 15 seconds.
Cybersecurity experts told Fox News Digital that a cyberattack on French supermarket freezers should warn the U.S. about critical infrastructure gaps.
The Oracle Health breach exposed medical records, Social Security numbers and diagnoses of nearly 20 million patients across multiple states.
The new Tesla Roadster drove upside down and launched into the air at SpaceX's Texas facility, but a 2028 production target remains unconfirmed.
Apple's iOS 27 lets you add keywords to iPhone photos, while Samsung Gallery tags and Google Photos search offer similar organization tools.
A fake Claude AI download scam uses Google ads, and Bing redirects to trick Mac users into pasting a hidden malicious command in their Terminal.
Ahold Delhaize's cybersecurity incident knocked online ordering and digital coupons offline at Stop & Shop, Food Lion, Hannaford and Giant Food stores.
The Fox News AI Newsletter covers the latest artificial intelligence technology advancements, including the challenges and opportunities AI presents now and for the future.
Amazon's About You feature includes personality details from your shopping history, and some shoppers are finding hilariously awkward results.
Identity theft recovery starts with securing bank accounts, freezing credit and enabling two-factor authentication within the first 24 hours.
Apple's $299 HomeView smart display uses facial recognition to personalize screens for up to six household members and show live security camera feeds.
Domonique DuBose spotted red flags when a man on Hinge with 85,000 followers and a blue checkmark claimed to be a San Francisco 49ers player.
Your phone's location data can expose visits to doctors, pharmacies and places of worship. The FTC took action against data brokers selling this data.
Hackers targeted Danfoss refrigerator controls across French supermarkets, forcing chains like Carrefour and Monoprix to discard massive food stocks.
iOS 27 finally lets iPhone Shared Albums store photos and videos at full resolution in iCloud, but new items count toward the owner's storage.
A fake Facebook Marketplace text scam uses your real name as the seller to trick you into replying, and Malwarebytes warns even one response helps.
The Pentagon data breach exposed 2.76 million Social Security numbers and military records, raising long-term identity theft concerns for veterans.
Kodiak AI plans to haul IKEA freight on Texas highways with no one in the cab, raising urgent cybersecurity and safety questions for drivers.

3 Reasons Why Medical Billing Software is Leading the Way

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

Manufacturing Solutions for Microsoft Great Plains ? Overview for Consultant

Microsoft Business Solutions Great Plains has full-featured manufacturing set of... Read More

SQL scripts for Project Accounting: Microsoft Great Plains series ? overview for developer

Microsoft Business Solutions Great Plains has Project Accounting module where... Read More

How to Backup Windows XP Home Edition

Your computer cost you from hundreds to thousands of dollars,... Read More

Microsoft Great Plains version 8.5: Upgrade, Customization, VBA, Crystal Reports - Highlights

Microsoft Great Plains is one of the Microsoft Business Solutions... Read More

The Secret of the Layer Styles Dialogue

When you double-click a layer in the Layer Palette, you... Read More

Passwords Used In Microsoft Word Documents

You would like to protect your documents, wouldn't you? Reasons... Read More

Microsoft Great Plains on Ctree or Pervasive SQL ? What to Do ? Tips for IT Manager

As you probably know, when Microsoft purchased Great Plains Software... Read More

Microsoft CRM ? Consulting in the Post-Recession Time

New post-recession era has new features, which didn't exist in... Read More

Microsoft Great Plains eCommerce: overview for developer

Microsoft Business Solutions Great Plains was designed back in the... Read More

Reduce Pop-ups and Annoying Ads

There is many things more frustrating than surfing a website... Read More

An Easy Way to Deal with Email Viruses and Worms

If you feel intimidated when someone tries to teach you... Read More

The Religion And Philosophy Of Small Internet Business

I have always had a tendency to focus on the... Read More

Microsoft Great Plains Implementation for Large Corporation ? Overview for VP IT

Microsoft Business Solutions Great Plains was historically designed to serve... Read More

10 Ways to Learn a Software

Following tips help you to learn a software in lesser... Read More

10 Things You Can Do With Photoshop CS2 That You Couldnt Do Before Now

Is Photoshop CS2 worth the upgrade? You bet it is!... Read More

An Easy Way to Develop JAVA Enterprise Applications

Research bears that less than 70 percent of development projects... Read More

5 Mac Security Tips You Can?t Live Without

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

Recent Studies Show that 9 out of 10 PCs Are Infected with Spyware

Spyware and malware are large problems for Internet users today... Read More

Ukraine: a Prospective Player on the World Software Outsourcing Market

The destruction of the Soviet Union about 15 years ago,... Read More

Know-how in Microsoft Publisher

For those who still don't know, Microsoft Publisher helps computer... Read More

Know Linux

Linux essentials:It's free for download but you have to pay... Read More

Industry Experts Answer the One Million-dollar Question - Why Genie Backup Manager?

Many reasons made GBM a unanimous choice for experts, one... Read More

Microsoft Great Plains Logistics & Warehouse Management ? Implementation & Customization Highlights

Logistics automation is often considered as barcoding extension to Sales... Read More

Microsoft Great Plains: exchange & brokerage ? implementation notes

If you company is small or mid-size special products or... Read More

scheduled maid service Glenview ...