O'Reilly logo

Microsoft Exchange Server PowerShell Cookbook - Third Edition by Mike Pfeiffer, Jonas Andersson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exporting attachments from a mailbox

The Exchange Management Shell provides cmdlets that allow you to export e-mail messages from one mailbox to another. These e-mails can then be exported to a PST file, or you can open an alternate mailbox and access the data. The only limitation is that this provides no option to export only the message attachments. The EWS Managed API has this built-in functionality. In this recipe, you'll learn how to export e-mail attachments from an Exchange mailbox using PowerShell.

How to do it...

Let's see how to export attachments from a mailbox using the following steps:

  1. First, load the assembly, create the ExchangeService object, and connect to EWS:
    Add-Type -Path C:\EWS\Microsoft.Exchange.WebServices.dll
    $svc = New-Object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required