Skip to content

techspence/EWSEmailAttachmentSaver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

EWS Email Attachment Saver

This script looks for specific emails in an exchange users mailbox, downloads the attachments, then marks those emails as read and moves the messages to a processed folder for archiving.

Outline

  1. Determines the Folder ID of the processed folder
  2. Finds the correct email messages based on defined search filters (e.g. unread, subject, has attachments)
  3. Copy's the attachments to the appropriate download location(s)
  4. Mark emails as read and move to the processed folder

Check out my Blog Post: Using Powershell and Microsoft EWS Managed API to download attachments in Exchange 2016

Requirements

  • Exchange 2007 or newer
  • Exchange Web Services (EWS) Managed API 2.2

Additional Information

The processed folder is a subfolder of the root of the users mailbox (e.g. \\email@company.com\ProcessedFolder). The root of a users mailbox is called the Top Information Store. If your processed folder is a subfolder under any other folder you must change $processedfolderpath and $tftargetidroot appropriately.

To quickly view the outlook folder location, right click on a folder in outlook, then click properties.

Example: processed folder is a subfolder of the root mailbox: Location: \\email@company.com\ProcessedFolder

$processedfolderpath = "/ProcessedFolder"
$tftargetidroot = New-Object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot,$mailbox)

Example, processed folder is a subfolder of Inbox: Location: \\email@company.com\Inbox\ProcessedFolder

$processedfolderpath = "/Inbox/ProcessedFolder"
$tftargetidroot = New-Object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$processedfolderpath)

Future Enhancements

  • Create a Windows Service that will run the EWS Attachment Saver on an interval to check for applicable emails

Credits/Resources

About

A Powershell script that looks for specific emails in an exchange users mailbox, downloads the attachments, then marks those emails as read and moves the messages to a processed folder for archiving.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published