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:

AFP

SAP to buy Ariba, boosts cloud bet
Reuters
By Noel Randewich and Jim Finkle | SAN FRANCISCO (Reuters) - Top European software company SAP AG plans to buy Ariba Inc in a deal valuing the business and commerce network company at $4.3 billion, its latest maneuver against Oracle in the fast-growing ...
SAP to Acquire Ariba for $4.3 Billion in Biggest Push Into CloudSan Francisco Chronicle
SAP to buy Ariba for $4.5B, extending cloud pushBusinessWeek
SAP Agrees to Acquire Ariba in $4.3 Billion DealBloomberg
Los Angeles Times -Wall Street Journal -New York Times
all 311 news articles »


Wondershare Software Co. PDF Converter Pro
PCWorld
Wondershare Software Co. PDF Converter Pro Review, by Alan Stafford May 22, 2012 One-trick-pony software applications often play useful roles, especially if they have secondary advantages such as a lower price, smaller memory requirements, ...

and more »


Shunra Software Sponsors HP Discover 2012
San Francisco Chronicle (press release)
Shunra Software, the industry-recognized authority in network virtualization and application performance engineering, will offer three educational sessions at HP Discover 2012 and will be exhibiting its capabilities in booth 126.

and more »


CBS Local

Business software provider's revenue strong
Detroit Free Press
The business software and services provider also said the company is still on track to do an initial public offering of 20% of its Covisint subsidiary this fall or winter. Covisint is a provider of online business-to-business service platforms that ...
Compuware Profits Fall Despite Higher RevenueCBS Local

all 21 news articles »


Tableau Software Continues Global Expansion with Latin America Launch
Seattle Post Intelligencer
Tableau Software, the global leader in rapid-fire business intelligence software, today announced its launch in Latin America. International sales veteran Miguel Nhuch will lead the company's efforts to expand in the region, delivering fast analytics, ...

and more »


Calyx Software Named RegulatorConnect Certified Partner
MarketWatch (press release)
DALLAS, TX, May 22, 2012 (MARKETWIRE via COMTEX) -- Calyx Software(R), the preferred mortgage solution provider for banks, credit unions, mortgage bankers and brokers, announced today that they have been awarded RegulatorConnect(R) Certification by ...

and more »


BobCAD-CAM, Inc. Releases Latest Software for Manufacturing
San Francisco Chronicle (press release)
CNC Machining Software Pioneer BobCAD-CAM Officially Releases Its Version 25 Advanced Machining System to Global Manufacturing Markets Clearwater, FL (PRWEB) May 22, 2012 As manufacturers seek to reduce waste, increase productivity and long term ...

and more »


Marin Software Sees Explosive Adoption of Professional Edition
MarketWatch (press release)
SAN FRANCISCO, CA, May 22, 2012 (MARKETWIRE via COMTEX) -- Marin Software, provider of the leading digital ad management platform for advertisers and agencies, today announced since its debut in March 2011 more than 300 brands worldwide have adopted ...

and more »


AFP

Internet domain name project relaunches after software bug
Reuters
By Georgina Prodhan | LONDON (Reuters) - A project to allow companies to set up a website with almost any address has relaunched after a software glitch exposed sensitive details of applications last month, forcing it to shut down.
ICANN resumes bids for new Internet suffixes after software glitch shut down ...Washington Post

all 124 news articles »


Take-Two Interactive Software, Inc. Reports Results for Fourth Quarter and ...
MarketWatch (press release)
Take-Two Interactive Software, Inc. (NASDAQ:TTWO) today reported financial results for the fourth quarter and fiscal year ended March 31, 2012, which were in line with its most recent financial outlook. In addition, the Company provided its financial ...

and more »

Google News

home | site map
© 2006