Software Information

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.adFailIfNotExists,

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 (www.albaspectrum.com), he is Dexterity, SQL, VB/C#.Net, Crystal Reports and Microsoft CRM SDK developer.


MORE RESOURCES:

ABC News

Apple unveils software updates, new laptop
San Francisco Chronicle,  USA - 8 hours ago
The presentation included updates to the iLife and iWork software suites, a new 17-inch MacBook Pro with an 8-hour battery and a new digital rights ...
Video: Steve Jobs Weight Loss Due to Hormone Imbalance AssociatedPress
Apple's Macworld Surprise Is the Software PC Magazine
Apple updates Mac software in trade show finale The Associated Press
Seattle Post Intelligencer - Reuters
all 2,828 news articles


Times Online

ITunes embraces 3-tier pricing, will remove anti-copy software
Los Angeles Times, CA - 10 hours ago
Apple also updated much of its software. The latest version of iPhoto scans for individual faces so computer users can label photos of friends or family, ...
Macworld goes for the soft sell with budget-minded software USA Today
Apple removes protection software from songs TourDates.Co.Uk
Apple changes iTunes pricing CNNMoney.com
Bloomberg - Shiny Shiny
all 1,024 news articles


Rediff

Indian Software Giant Admits Financial Wrongdoing
Washington Post, United States - 2 hours ago
The revelation shook India's stock market and sent shock waves across the country's booming software industry, while television commentators quickly dubbed ...
Satyam Chairman Resigns After Falsifying Accounts Bloomberg
Collateral Damage Feared From 'India's Enron' CNNMoney.com
FACTBOX - Five facts about Indian outsourcer Satyam Reuters India
Reuters - Forbes
all 1,122 news articles


BMC Software stock up after analyst upgrade
Forbes, NY - 17 hours ago
AP , 01.06.09, 06:18 PM EST BMC Software Inc. shares climbed Tuesday after a UBS analyst upgraded the business software maker, saying its cost cutting ...
BMC Software (BMC) NewsBite - BMC Upgraded By UBS Market Intelligence Center
Movers roundup: Best Buy, BMC Software Forbes
all 9 news articles


DailyTech

Apple Unveils Software, MacBook At Macworld
CNNMoney.com - 21 hours ago
The first hour of the speech was dominated by updates to Apple's software line, which remains an important element for the company, but more as a driver to ...
Summary: Software, MacBook Pro updates star in final Apple keynote Macworld
Apple rolls out 17-inch MacBook Pro, new software, iTunes Store tweaks DVICE
Apple updates iTunes, iLife, unveils 17-inch MacBook Bizjournals.com
Silicon Alley Insider - CNN International
all 230 news articles


New York Times

Data Analysts Captivated by R’s Power
New York Times, United States - 1 hour ago
R first appeared in 1996, when the statistics professors Robert Gentleman, left, and Ross Ihaka released the code as a free software package. ...


Save Mart Supermarkets Deploys Integrated Retalix Supply Chain ...
MSNBC - 15 hours ago
That's why we turned to Retalix -- for the experience of their personnel and the rich grocery functionality of the company's software. ...
Save Mart Supermarkets deploys Retalix suite to enhance business ... Trading Markets (press release)
all 8 news articles


Software maker Scientific Learning to cut 14% of work force
Bizjournals.com, NC - 1 hour ago
Scientific Learning, which makes educational software, has made top management changes recently. On Jan. 2 the company named its president and chief ...


CNET.com.au

Phoenix Software Reduces Pain From a PC Boot
U.S. News & World Report, DC - 1 hour ago
HyperSpace is new software that offers a lean, fast and friendly partner to slow-starting Windows. I've been testing it for several days, and HyperSpace has ...
Phoenix Offers Faster Boot Times for Laptops PC World
A peek at Phoenix HyperSpace eWeek
all 42 news articles


Earthtimes (press release)

IBM Lotus Delivers New "Social" Notes and Free Symphony Software ...
CNNMoney.com - 19 hours ago
At Macworld, IBM (NYSE: IBM) today announced the availability of Lotus Notes 8.5 collaboration software with social computing features for all Mac OS X ...
Macworld: IBM finalizing free Symphony office suite for Macs Computerworld
Lotus Notes 8.5 ships, free IBM Symphony suite coming MacNN
IBM unveils Lotus Notes 8.5 VNUNet.com
eWeek - Computer Business Review
all 43 news articles

Software - Google News

home | site map
© 2006