VBA Site contains VBA code to create macros in WORD EXCEL ACCESS OUTLOOK

 

1) Saving attachment to disk excluding *.png file

Public Sub saveAttToDisk(item As Outlook.MailItem)

Dim objAtt As Outlook.Attachment

Dim saveFolder As String

saveFolder = "C:\YourFolder\"    'change path as you wish

For Each objAtt In item.Attachments

If Right$(objAtt.DisplayName, 3) = "png" Then 'in this case all files with extension "png" will be excluded (this excludes signatures)

GoTo LastLine

Else

objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName  

Set objAtt = Nothing

End If

LastLine:

Next

End Sub

2) Saving attachment to disk excluding *.* any file types

Part of the code below

For Each objAtt In item.Attachments

If Right$(objAtt.DisplayName, 3) = "png" Then 'in this case all files with extension "png" will be excluded (this excludes signatures)

GoTo LastLine

Else

If Right$(objAtt.DisplayName, 3) = "jpg" Then 'in this case all files with extension "jpg" will be excluded (this excludes signatures)

GoTo LastLine

Else

If Right$(objAtt.DisplayName, 4) = "jpeg" Then 'in this case all files with extension "jpeg" will be excluded (this excludes signatures)

GoTo LastLine

Else

If Right$(objAtt.DisplayName, 3) = "bmp" Then 'in this case all files with extension "bmp" will be excluded (this excludes signatures)

GoTo LastLine

Else

objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName

Set objAtt = Nothing

End If

End If

End If

End If



Dodaj komentarz






Dodaj

© 2013-2024 PRV.pl
Strona została stworzona kreatorem stron w serwisie PRV.pl