LTN Law Technology News
  • Home
  • News
  • Reviews
  • Commentary
  • Surveys
  • Events
  • LegalTech® Directory
  • About LTN
  • Register
  • Topics:
  • E-Discovery & Compliance
  • Litigation Support
  • Practice Management
  • Office Tech
  • Mobile Lawyer
  • Research & Libraries
  • Tech Law

Home > Managing Email With Exchange Web Services

Font Size: increase font decrease font

Managing Email With Exchange Web Services

By Mark Gerow All Articles 

Law Technology News

March 5, 2013

  •    
  •    
  •    
  •      
 
Mark Gerow, director of application development and business process at Fenwick & West

Mark Gerow, director of application development and business process at Fenwick & West

We hear a lot today about "activity streams" — those scrolling lists of posts, comments, and "likes" that provide the substance of social media sites and blogs. But inside the enterprise, one activity stream reigns supreme: email; and for most firms email means Exchange. While the centrality of email within the 21st century law firm is assumed, managing its content can be a challenge. Beyond inbox quotas and automated archiving, how can IT help manage this flood of unstructured data in a way that promotes matter team collaboration?

One way is through Exchange Web Services (EWS), the set of services upon which Outlook Web Access (OWA) is based, and which provides all the core tools for finding, moving, updating and deleting email. As a tool for manipulating Exchange content EWS has several advantages over Outlook add-ins, including:

• It is not dependent on the version of Outlook installed on the user's desktop (in fact, a local Outlook client is not required).

• EWS does not need to be run from the user's computer, but can be centralized on a network server.

• With appropriate configuration of Exchange, EWS can manipulate the contents of any user's email and calendars, allowing for the development of centralized, firmwide applications.

In this article I will show how EWS may be used to find emails in an inbox matching a certain criterion, upload those matching emails to SharePoint, and move the original emails to the Outlook "Deleted Items" folder. Through this example you will learn the basics of working with email using EWS.

INSTALLING EWS ON A DEVELOPMENT COMPUTER

One nice thing about EWS is that the web service calls are "wrapped" in a class library that can be referenced in .NET, so it's not necessary to interact directly with the web service per se, only to instantiate objects based on the classes in the library, which can be found here. The version I've worked with successfully is 1.2, although there's a later 2.0 version available for download but as of this writing it appears to still have some bugs.

THE SHAREPOINT "COPY" WEB SERVICE

In addition to EWS, we will use SharePoint's built-in "Copy" service to upload emails to a document library. To use this service you will need to add a web service reference to your Visual Studio solution pointing to the URL: http://[your server name]/[path to site]/_vti_bin/copy.asmx.

GETTING CONNECTED TO YOUR EXCHANGE SERVER

To work with Exchange you need a connection specifying the location of the corresponding EWS instance and authorized user credentials. The following routine will get you connected to the inbox associated with the current application user's credentials:

For the complete code used in this story, see the .cs or .pdf file.

Note: EWS allows you to connect to any individual's inbox given sufficient permissions. Such permissions must be granted by your Exchange administrator. See here for more information.

RETRIEVING THE CONTENTS OF AN INBOX

It's often simpler to manipulate inbox content if it's first copied to a DataTable. The following method, "GetInbox" will read through the first items in an inbox that have a specified string in the subject, adding the data for those emails to a Data Table for later processing.

Click image to enlarge
Click image to enlarge.

RETRIEVING A SINGLE ENTRY BY ITS EXCHANGE ID

Each email message has a unique ID that can be used to retrieve its contents.

GETTING THE EMAIL FILE

To upload an email to SharePoint, we need to get the full email as a byte-array. Note that the "Load( )" method is called with a special parameter to get the "MimeContent". This is necessary in order to make the full byte-array representation of the email message available.

UPLOADING THE EMAIL TO SHAREPOINT

Once the metadata and byte-array contents of the email are available, we can use SharePoint's copy.asmx web service to upload a copy of the email to a document library.

DELETING A MESSAGE FROM THE INBOX

Finally, we want to delete the message after it has been uploaded to SharePoint:

message.Delete(DeleteMode.MoveToDeletedItems);

ALMOST, BUT NOT QUITE!

The selected documents are now in a SharePoint library, but they may not open correctly until a setting has been changed on your IIS server.

Click image to enlarge
Figure 1. Click image to enlarge

The reason is that EWS returns emails in the .EML format used by Exchange, not the .MSG format used by Outlook. In order to instruct Outlook to open these messages, you need to associate the .EML extension with the "application/octet-stream" MIME type. This tells Windows that the .EML file type should launch an application.

Click image to enlarge
Figure 2. Click image to enlarge

You may also need to have individual users associate the .EML document type with Outlook. This can be done by pushing a group policy out to all users, or individually by right-clicking on an .EML file and using the "Open with" option to associate Outlook with that type. See Figure 3.

Click image to enlarge
Figure 3. Click image to enlarge

CONCLUSION

Exchange Web Services, the set of services behind Outlook Web Access, can be a powerful ally in taming the email beast. EWS allows you to search through an inbox and process emails without end-user intervention. It also has an advantage over the Outlook object library in that EWS can run on any computer, does not require Outlook to be installed, and with sufficient permissions, allows you to open any inbox for processing.

Mark Gerow leads the application development team at Fenwick & West and is responsible for defining and implementing the firm's intranet and extranet strategies using SharePoint technologies. Email: mgerow@fenwick.com.



Subscribe to Law Technology News

You must be signed in to comment on an article

Find similar content

Companies, agencies mentioned

    
  • IIS
  • EWS
  • CONNECTED TO YOUR EXCHANGE SERVER
  • Data Table
  • CONCLUSION Exchange Web Services
  • Web Service Company

Key categories

    
  • Networking, Storage, Content

Most viewed stories

    
  1. 10 Devices You Should Never Take Along on a Business Trip
    •      
  2. Is Stanford Law the New Vortex of Legal Technology?
    •      
  3. Redacted Emails Ordered Released in Aaron Swartz Case
    •      
  4. Using Computer Forensics to Investigate IP Theft
    •      
  5. Law Technology News Goin' Mobile With ALM
    •      
  6. CEIC: the Destination for Digital Investigation
    •      
  7. FTC Warns Companies of Children's Privacy Violations
    •      
  8. Judge Opens Toyota's Secrets to Additional Attorneys
    •      
  9. How the Predictive Coding Process Will Affect Paralegals
    •      
  10. Collaboration Is Key to Defending Cyberattacks
    •      
lawjobs.com

TOP JOBS

MORE JOBS

POST A JOB

From the Law.com Network

Taking the Reins of Legal Department Operations

In-House Law: Now in 3-D!

Simpson Helps Yahoo, Tumblr Connect for $1 Billion Deal

Kasowitz Benson Launches in Los Angeles

Contrite Companies Can Win Forgiveness in Bribery Cases
  •      
    • Subscription Required

Plaintiffs Want to See Toyota's 'Crown Jewels'
  •      
    • Subscription Required

Collaboration Is Key to Defending Cyberattacks

Stanford Law Builds on Role as Legal Tech Incubator

Prolific ADA Plaintiff Faces Nemesis in Harassment Suit

Ullyot Exit Closes Chapter for Facebook

Rothstein Bankruptcy Trustee Files New Reorganization Plan
  •      
    • Subscription Required

Fla. Bar Wants Disbarment for Former Judge
  •      
    • Subscription Required

Appellate Division To Roll Out Electronic Case Filing System

Court Limits Liability for Injury Or Death of One Invited To Help
  •      
    • Subscription Required

The Affordable State-Specific Practice Solution
Available in NY, NJ, PA and CT editions - research, draft and prepare even the most complex cases with ease.

Judge Declines to Block Act-of-War Defense in 9/11 Case
  •      
    • Subscription Required

Panel Finds 'Excessive' City Fine for Poaching Antenna From Trash
  •      
    • Subscription Required

Lawsuit Testing Federal Porn Regulation Allowed to Survive

Ex-College QB Can Press Claim Over EA's Video Game
  •      
    • Subscription Required

Law Schools Are Looking Beyond LSATs, Says Mich. Dean

Is Freezing Your Eggs the Solution?

Water Warriors: Local Governments Bring Pollution Suits
  •      
    • Subscription Required

Sanction Reversed; Filing of Sexually Explicit Chat OKd
  •      
    • Subscription Required

Brooks Looks To Political Ally For Criminal Defense

Attorney Fee Hearing in Waffle House Sex Case Heats Up
  •      
    • Subscription Required

Corporate Bribery Case Part Of National Trend
  •      
    • Subscription Required

Court Continues To Grant Lawyers Fraud Immunity
  •      
    • Subscription Required

  • Contact LTN
  • Editorial Guidelines
  • Magazine
  • RSS Feeds
  • LTN Awards
  • Bookstore
  • Site Map
  • About |
  • ALM Properties |
  • ALM Reprints |
  • Customer Support |
  • Privacy Policy |
  • Terms & Conditions |
  • ALM User License Agreement
ALM Media