sgcareerman
09-03-2012, 05:18 AM
I am a noob in VBA programming, can only understand basic function and usage also some simple coding modification
I use the following VBA coding in outlook 2010 to auto extract all attachment from emails that i receive but i face a issue that it also extracts images in the emails as attachment too.
How can I modify the coding to not save attachment if it does not match certain files types?
I also need the coding not to save attachment if the file size is more than 3 MB.
Experts and pro kindly help.
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "c:\temp"
For Each objAtt In itm.Attachments
stFileName = saveFolder & "\" & objAtt.DisplayName
i = 0
JumpHere:
If Dir(stFileName) = "" Then
objAtt.SaveAsFile stFileName
Else
i = i + 1
stFileName = saveFolder & "\" & i & " - " & objAtt.DisplayName
GoTo JumpHere
End If
Set objAtt = Nothing
Next
itm.Delete
End Sub
I use the following VBA coding in outlook 2010 to auto extract all attachment from emails that i receive but i face a issue that it also extracts images in the emails as attachment too.
How can I modify the coding to not save attachment if it does not match certain files types?
I also need the coding not to save attachment if the file size is more than 3 MB.
Experts and pro kindly help.
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "c:\temp"
For Each objAtt In itm.Attachments
stFileName = saveFolder & "\" & objAtt.DisplayName
i = 0
JumpHere:
If Dir(stFileName) = "" Then
objAtt.SaveAsFile stFileName
Else
i = i + 1
stFileName = saveFolder & "\" & i & " - " & objAtt.DisplayName
GoTo JumpHere
End If
Set objAtt = Nothing
Next
itm.Delete
End Sub