[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

Archiving attachments for a specified mailbox.

Recently I received a request to automatically archive attachments that come into a specific mailbox to a network directory. After the attachment has been archived the message that containined the attachment should be deleted.  I have attempted creating a VBscript to do this but have been unsuccessful in finding a resolution to this thus far. EMC's EmailXtender is also not capable of doing this. Does anyone out there know of a way to accomplish this? Thanks to all for taking the time to read through this question, hopefully there is an answer out there!

-Mitch
0
MitchV85
Asked:
MitchV85
  • 4
  • 2
1 Solution
 
peakpeakCommented:
You can accomplish this with the built-in Auto-Archive feature in Outlook. Right-click Inbox for the mailbox in question and choose Properties. On the Auto-Achive (or similar) tab you find ia mulitude of settings. Select 0 days and select Move to the specified folder.
0
 
David LeeCommented:
Hi, Mitch.

I can do this with a simple bit of scripting.  The only question I have is what you mean when you say "archiving".  Are you expecting this to work via the archiving process?  If so, then that's not possible.  Or does archiving mean to run a an archiving like process?  If so, then that's easy.  

0
 
David LeeCommented:
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
MitchV85Author Commented:
First PeakPeak, thank you for the reply however I do not want to have a PST file to which the messages are archived to.

BlueDevilFan, when I had said archiving you are correct in that I was looking for an archive-like process. Something that will extract the attachments from the messages and move them to a specified network volume. After the attachment has been moved the message should be deleted. If you have a script that will perform this action I will petition to award you 2000 points. :)

Thanks both for the replies!

-Mitch
0
 
David LeeCommented:
Mitch,

Here you go.  Follow these instructions to use this.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Modules and click on Module1 (if you expand the tree in the top left pane and don't see Module; right click on "Project 1" and choose "Insert Module", then hightlight "Module 1" so you can paste into it in the right hand pane)
4.  Copy the code below and paste it into the right-hand pane of the VB Editor
5.  Edit the code as needed.  I inserted a comment line immediately before each line that needs to be changed.
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools->Macro->Security
9.  Change the Security Level setting to Medium
10.  If the file system folder where attachments will be saved doesn't already exist, then create it.
11.  Select an Outlook folder by clicking on it.
12.  Run the macro.  It will prompt for a cutoff date when it launches.  All messages dated before the cutoff date will be processed by the macro.  All attachments will be saved into the designated file system folder and the source message deleted.  


Sub RemoveAttachmentsBasedOnDate()
    Dim olkFolder As Outlook.MAPIFolder, _
        olkItem As Object, _
        olkAttachment As Outlook.Attachment, _
        strCutoff As String, _
        strTitle As String, _
        strAttachmentFolder As String, _
        intIndex As Integer
    'Change the folder path on the following line to the folder on your system where attachments will be saved
    strAttachmentFolder = "C:\eeTesting\MyAttachments\"
    strTitle = "Remove Attachments Based on Date"
    'Change the default date on the following line as needed
    strCutoff = InputBox("Enter a cutoff date.  Aattachments on all messages prior to that date will be saved and the source message deleted.", strTitle, Date - 30)
    If Not IsDate(strCutoff) Then
        MsgBox "You failed to enter a valid date.  The macro is aborting.", vbCritical + vbOKOnly, strTitle
        Exit Sub
    End If
    Set olkFolder = Application.ActiveExplorer.CurrentFolder
    For intIndex = olkFolder.Items.Count To 1 Step -1
        Set olkItem = olkFolder.Items.Item(intIndex)
        If olkItem.ReceivedTime < CDate(strCutoff & " 00:00:01 AM") Then
            If olkItem.Attachments.Count > 0 Then
                For Each olkAttachment In olkItem.Attachments
                    olkAttachment.SaveAsFile strAttachmentFolder & olkAttachment.FileName
                Next
                olkItem.Delete
            End If
        End If
    Next
    Set olkAttachment = Nothing
    Set olkItem = Nothing
    Set olkFolder = Nothing
    MsgBox "All done!", vbInformation + vbOKOnly, strTitle
End Sub
0
 
MitchV85Author Commented:
$$$ Thanks BlueDevilFan, worked great!
0
 
David LeeCommented:
You're welcome, Mitch.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now