I am in need of some help with a script.
Purpose of the script: The script is used to detach the attachment (i.e. pdf, csv, xml) from the email and save it on a network drive. Using a rule to automatically execute the script, I am able to copy the csv files in to a network file share.
Script current configuration: The Outlook rule points to one outlook folder (called Region2) and pulls all attachment files(based on Subject filed) and then saves it in network folder.
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
Const save_path As String = "\\Network share\"
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) - 5)
save_name = save_name & Format(objMail.ReceivedTime, "_mm-dd-yyyy")
save_name = save_name & Right(objAtt.FileName, 5)
objAtt.SaveAsFile save_path & save_name
Set objAtt = Nothing
Set objMail = Nothing
Set objNS = Nothing
What I wanting to do: I am looking to upgrade the script to pull attachments from 3 different outlook folders (i.e. Region1, Region2, and Region3) and place them in to their respective (based on email address and subject line) folders on the network share named “ Region 1, Region 2, and Region 3."
Is this possible to with the current script or do I need to scarp it….