Macro to save attachment to a folder

  • Thread starter Thread starter Julia
  • Start date Start date
J

Julia

I am new to macros and am needing to creat a macro that
when run will look at the current email, save the
attachment(s) to a folder, move the email to a different
folder, then repeat for all emails in the current
folder. I am not sure where to start or what reference
book(s) to use. I have written macros in excel (mostly
recorded) before but a little lost with the outlook
terminology.
 
I too am trying to do the same thing
It seems that the rules wizard is the best way to go and then use the script command to move it thats where i have fallen over I can get it to work when the incoming mail is active not when i am doing something else. Hope this helps abit if you do find another way please email me at
 
I have added it to the rules wizard as a script.

this works if you foward a message to your self and have the forward message open it works, but if you have either another or none open it doesnt work

Sub CustomMailMessageRule(Item As Outlook.MailItem)
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem
Set myAttachments = myItem.Attachments
myAttachments.Item(1).SaveAsFile "C:\" & myAttachments.Item(1).DisplayName
End Sub

hopefully someone will look at this and see wher i am going wrong
 
CurrentItem is the item that's open. Item is the item that your rule is
running against. You need to remove the reference to CurrentItem and replace
myItem with Item throughout.

These samples show a couple of other ways to save attachments:

http://www.outlookcode.com/codedetail.aspx?id=70
http://www.slovaktech.com/code_samples.htm#StripAttachments

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Corv said:
I have added it to the rules wizard as a script.

this works if you foward a message to your self and have the forward
message open it works, but if you have either another or none open it doesnt
work
 
Thanks works a treat. Though I did not realise at first you ment remove the line reffering to myitem
 
Back
Top