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.

Willow Springs limo O'Hare .. Lockport Chicago limo O’Hare
In The News:

Tech expert Kurt “CyberGuy" Knutsson discusses how robots can milk, feed and clean cows on dairy farms, boosting efficiency and comfort.
Tech expert Kurt “CyberGuy" Knutsson says quantum internet ensures unhackable security and redefines online privacy and speed.
Kawasaki's CORLEO is a hydrogen-powered, AI-driven rideable robot. Tech expert Kurt “CyberGuy" Knutsson reports on this new way of thinking about off-road transportation.
The CyberGuy breaks down five mobile privacy terms that could make a difference when it comes to keeping your personal information safe.
A groundbreaking robot that's like a real-life Wall-E uses advanced artificial intelligence to replicate natural gestures and deliberate actions with striking accuracy.
If not properly managed, Windows Defender Application Control, a security feature with Windows, could be a potential security vulnerability.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
FlashBot Arm, a semi-humanoid robot, acts more like a human than traditional robots, and you may see it working at a restaurant, healthcare center or hotel.
There are multiple ways to find your missing Android phone after it goes missing. One method involves using a smartwatch to ping your phone.
The NeuroOne OneRF Ablation System is a new device with FDA-cleared technology designed for both diagnosing and treating neurological disorders in one procedure.
The CyberGuy provides tips to protect yourself from criminals who use various methods to make unauthorized transactions using your account information.
New drone technology maps land and water with stunning accuracy, giving researchers and conservationists a new way to understand our planet.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
X hit with massive data breach with 200 million records leaked, including emails. Tech expert Kurt “CyberGuy" Knutsson offers seven tips to help protect yourself.
Atlas robot by Boston Dynamics amazes tech expert Kurt “CyberGuy" Knutsson with its breakdancing moves.
Tech expert Kurt “CyberGuy" Knutsson talks about how Google kept Android SafetyCore details quiet until it scanned users' photos.
Hydrogen trucks debut in Georgia, sparking debates on costs and green freight gains. Kurt “CyberGuy" Knutsson comments on this promising chapter in green logistics evolution.
Tech expert Kurt “CyberGuy" Knutsson says ChatGPT learns from chats, but you should avoid sharing sensitive information to protect your privacy.
Beyond Aero's BYA-1: Hydrogen-electric jet with zero emissions, reduced costs, 2030 launch. Kurt “CyberGuy" Knutsson discusses a potential game changer in the evolution of air travel.
Kurt "CyberGuy" Knutsson explains how you can creatively repurpose your old unused Android devices, which are full of potential and hidden value.
Mech the super-humanoid robot can lift up to 132 pounds and is designed to tackle stressful and repetitive tasks that often lead to workplace injuries.
Double-clicking is something we all do, often without giving it a second thought. But it could be giving hackers permission to do something dangerous.
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 the CyberGuy offers some of his easy expert tips to free up storage space on your Android if your device is running short on storage.
You can reset your internet router remotely if you're not home when your power goes out. Kurt "CyberGuy" Knutsson explains how this can be done.

Microsoft Great Plains Customization Tools ? Overview

Former Great Plains Software Dynamics/eEnterprise, and currently Microsoft Business Solutions... Read More

Microsoft Great Plains Reporting ? Overview for Developer

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

Software Piracy - Global Increase

Pirated software is on the increase and now accounts for... Read More

Adware and Spyware Blockers

The most important things you can do for your computer... Read More

How To Develop Software For Your Business

Software development is a risky business.Many software developers are barely... Read More

Mapping Software: Putting Data Visualization on the Map

Mapping Software Improves Data VisualizationFrom the outset, it is important... Read More

Removing Incoming Email in MS Exchange, C# Example

The purpose of one of our projects was MS Exchange... 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

Perfectly New Database Query Tool - Foxy SQL Pro Released

Are you a database professional? Do you work with a... Read More

Microsoft Great Plains 8.0 Brazilian Version ? Overview For International Consultant

Microsoft Great Plains has substantial mid-market share in the USA... Read More

Microsoft Navision and Crystal Reports - An Overview

Microsoft Business Solutions ? Navision is an integrated solution for... Read More

Make or Break Factors - When Considering Estimating Software

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

Groove Network. Are you in it?

If you are in a business that passes documents around... Read More

eStore Advantage ? Extending Microsoft eConnect for MBS Great Plains

eStore Advantage allows front-office applications to communicate with back-office business... 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

Editing Your Photos Using Microsoft Picture It Publishing Platinum 2002 - A Great Dinosaur

I started using PIP (Picture It Publishing) Platinum 2002 right... Read More

Hear It in Digits

Music downloads are off the charts! We're listening to digital... Read More

Great Plains Dynamics on Pervasive/Ctree support ? overview for consultant

All of us know that Microsoft bought former Great Plains... Read More

Information Products: A Business Owners Best Friend

We live in a post-industrial age where information is the... Read More

The Importance of Timely Timesheets

Whether you are a small consultancy firm, a medium sized... Read More

ERP Consulting: Microsoft Great Plains Partner Future Directions

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

Downloading Spyware Removers: Think Before, not After

Just imagine: you are walking, say, towards your car, and... Read More

Adware, What Is It?

Adware is a type of Spyware program that displays some... Read More

Who?s Watching What You Type?

If someone entered your home, uninvited and installed numerous cameras... Read More

Configure Windows Indexing Service for Performance

The Windows Indexing Service provides you with the ability to... Read More

group transportation logistics management Highland ..