People still sending you MEGA attachments?

I had a friend come to me and ask how to automatically send attachments to a certain folder as she was tired of downloading the attachments and saving them to her hard drive only to *re* upload them to a file share for consumption.

I’m not much of a VBScript guy, but I knew this could be done, so I sent her the following script:

Sub SaveToFolder(MyMail As MailItem)
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim objMail As Outlook.MailItem
Dim objAtt As Outlook.Attachment
Dim c As Integer
Dim save_name As String

'Place path to sav to on next line. Note that you must include the
'final backslash

Const save_path As String = "<location where you want the file saved>"
StrID = MyMail.EntryID
Set objNS = Application.GetNamespace("MAPI")
Set objMail = objNS.GetItemFromID(strID)
If objMail.Attachments.Count > 0 Then
For c = 1 To objMail.Attachments.Count
Set objAtt = objMail.Attachments(c)
Save_name = Left(objAtt.FileName, Len(objAtt.FileName) - 4)
'save_name = save_name & Format(objMail.ReceivedTime, "_mm-dd-yyyy_hhmm")
Save_name = save_name & Right(objAtt.FileName, 4)
ObjAtt.SaveAsFile save_path & save_name
End If
Set objAtt = Nothing
Set objMail = Nothing
Set objNS = Nothing
End Sub

To make this work for your Outlook client, you first need to enable the Developer feature in Outlook options:


Then go to Outlook and select the Visual Basic button



Select ‘Insert Module’


Insert the code in the code window:


At this point you simply create a rule (which will run locally and only when your client runs Outlook) which runs the script when you receive the attachment.

image image


Then you are done! Every time you receive an email with an attachment, it will be stripped from the email and sent to the location you specified.  If you only want *certain* attachments to be stripped and shipped, then specify that in the rule.

Skip to main content