Hi,
I copied a save all attachment vba script and was able to modify the script to do what I want. However, because we are using an exchange server... this script is unable to grab the attachments my colleague send me - only external emails. Can anyone please help?
Thanks
I copied a save all attachment vba script and was able to modify the script to do what I want. However, because we are using an exchange server... this script is unable to grab the attachments my colleague send me - only external emails. Can anyone please help?
Thanks
Code:
Public Sub Save_Attach_To_Disk(itm As Outlook.MailItem)
If (itm.Attachments.Count >= 1) Then
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim objAtt As Outlook.Attachment
Dim dateFormat_file_name
dateFormat_file_name = Format(itm.ReceivedTime, "yyyy-mm-dd H-mm ")
Dim dateFormat_target_folder
dateFormat_target_folder = Format(itm.ReceivedTime, "yyyy-mm-dd")
Dim StrDomainName
StrDomainName = Right(itm.SenderEmailAddress, Len(itm.SenderEmailAddress) - InStr(1, itm.SenderEmailAddress, "@"))
''''''''''''''''''''''''''''''''''''''''''''
Dim Supplier_Folder As String
Supplier_Folder = "Z:\By Supplier" ' you can change the folder
Dim Date_Folder As String
Date_Folder = "Z:\By Date" ' you can change the folder
''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''
Dim saveFolder_Root2 As String
saveFolder_Root2 = Supplier_Folder & "\" & StrDomainName
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(saveFolder_Root2) Then
objFSO.CreateFolder (saveFolder_Root2)
End If
''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''
Dim saveFolder_ByDate As String
saveFolder_ByDate = Date_Folder & "\" & dateFormat_target_folder
If Not objFSO.FolderExists(saveFolder_ByDate) Then
objFSO.CreateFolder (saveFolder_ByDate)
End If
''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''
For Each objAtt In itm.Attachments
If (InStr(objAtt.DisplayName, ".PDF") Or InStr(objAtt.DisplayName, ".html") Or InStr(objAtt.DisplayName, ".msg") Or InStr(objAtt.DisplayName, ".htm")) Then
objAtt.SaveAsFile saveFolder_Root2 & "\" & dateFormat_file_name & " - " & objAtt.DisplayName
objAtt.SaveAsFile saveFolder_ByDate & "\" & dateFormat_file_name & " By " & StrDomainName & " - " & objAtt.DisplayName
End If
Set objAtt = Nothing
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End If
End Sub