Hi all
I tried looking on the post already but seem couldnt have an solution.
I would like to add something or below to the code which work at current. I would like to exclude all jpg and png file type.
'want to delete image file
If UCase(Right(objAtt.FileName, 3)) <> "PNG" And UCase(Right(objAtt.FileName, 3)) <> "GIF" Then
strFile = strPath & objAtt.FileName
objAtt.SaveAsFile strFile
objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
fso.DeleteFile strFile
End If
Im currently having this code work upon receiving each email and autosave the attachment.
Public Sub Test(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
From = itm.Sendername
saveFolder = "C:\Users\abcbac\Documents\Emailattachment"
For Each objAtt In itm.Attachments
stFileName = saveFolder & "" & Format$(itm.CreationTime, "yyyy.mm.dd hhmm - ") & From & " - " & objAtt.DisplayName
i = 1
JumpHere:
If Dir(stFileName) = "" Then
objAtt.SaveAsFile stFileName
Else
i = i + 1
stFileName = saveFolder & "" & Format$(itm.CreationTime, "yyyy.mm.dd hhmm - ") & From & (" - " & i & " - ") & objAtt.DisplayName
GoTo JumpHere
End If
Set objAtt = Nothing
Next