I'm currently using this vba script (locally on client) to strip email attachments from user's folder to and move to user document folder and then replace with a pointer in the email to reference the attachment.
Public Sub SaveOLFolderAttachments() Dim oShell As Object Set oShell = CreateObject("Shell.Application") Dim fsSaveFolder As Object Set fsSaveFolder = oShell.BrowseForFolder(0, "Please Select a Save Folder:", 1) If fsSaveFolder Is Nothing Then Exit Sub ' Note: BrowseForFolder doesn't add a trailing slash ' Ask the user to select an Outlook folder to process Dim olPurgeFolder As Outlook.MAPIFolder Set olPurgeFolder = Outlook.GetNamespace("MAPI").PickFolder If olPurgeFolder Is Nothing Then Exit Sub ' Iteration variables Dim msg As Outlook.MailItem Dim att As Outlook.attachment Dim sSavePathFS As String Dim sDelAtts For Each msg In olPurgeFolder.Items sDelAtts = "" If msg.Attachments.Count > 0 Then While msg.Attachments.Count > 0 ' Save the file sSavePathFS = fsSaveFolder.Self.Path & "\" & msg.Attachments(1).FileName msg.Attachments(1).SaveAsFile sSavePathFS If msg.BodyFormat <> olFormatHTML Then sDelAtts = sDelAtts & vbCrLf & "<file://" & sSavePathFS & ">" Else sDelAtts = sDelAtts & "<br>" & "<a href='file://" & sSavePathFS & "'>" & sSavePathFS & "</a>" End If msg.Attachments(1).Delete Wend If msg.BodyFormat <> olFormatHTML Then msg.Body = msg.Body & vbCrLf & vbCrLf & "Attachments Deleted: " & Date & " " & Time & vbCrLf & vbCrLf & "Saved To: " & vbCrLf & sDelAtts Else msg.HTMLBody = msg.HTMLBody & "<p></p><p>" & "Attachments Deleted: " & Date & " " & Time & vbCrLf & vbCrLf & "Saved To: " & vbCrLf & sDelAtts & "</p>" End If msg.Save End If Next End Sub
It works great on a small scale however becomes very tedious for multiple users and folders. I was wondering if there was a way to do this perhaps in powershell that I could loop all users and user folders against the exchange server itself ?
Exchange 2003 / Windows Server 2003