Nyanko
05-29-2013, 05:18 AM
I've been working with Excel VBA for years and now have a need to do a simple piece of work in Outlook.
I'm using the following code to save an attachment to a specific folder. However I need to rename the attachment as the subject of the email.
Private Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Temp\"
For Each objAtt In itm.Attachments
If objAtt.FileName <> "image001.gif" Then
objAtt.SaveAsFile saveFolder & "\" & objAtt.FileName
End If
Set objAtt = Nothing
Next
End Sub
I've tried researching but can't find the answer to something so simple ! And every effort I try results in a run time error - help :)
I'm using the following code to save an attachment to a specific folder. However I need to rename the attachment as the subject of the email.
Private Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Temp\"
For Each objAtt In itm.Attachments
If objAtt.FileName <> "image001.gif" Then
objAtt.SaveAsFile saveFolder & "\" & objAtt.FileName
End If
Set objAtt = Nothing
Next
End Sub
I've tried researching but can't find the answer to something so simple ! And every effort I try results in a run time error - help :)