Help with Saving Attachment with VBA from Rules

M

Murphybp2

I need some assistance creating a VBA that will save an attachment
from a message via Outlook Rules. I have read all the posts, and
various links to web pages with save attachments code, and still can't
figure it out. I think much of the code I saw was more complex than I
need. I receive a single email each day from a person with only 1
attachment. When the rule identifies that message, all I want to do
is save the attachment to a specific folder, with a new name that I
choose (not the name the attachment has already). Then delete the
email. That's it. I don't need to loop through any other messages or
scan for any other attachments. I'm using Outlook 2003. Here is what
I've tried to come up with, but it's not working.


Sub SaveAttachments(Item As Outlook.MailItem)

Dim myAttachments As Object

Set myAttachments = myItem.Attachments
myAttachments(1).SaveAsFile "J:\Health Business Operations\MSO
\Blue Options\BOSCO Resource Management\Standard Reports\MSO Daily
Report\Current Report\" & "MCC Daily Performance Scorecard.mdi"
Item.Delete
End Sub
 
S

Sue Mosher [MVP-Outlook]

You need to change myItem to Item, which represents the message the rule is acting on.
 
M

Murphybp2

You need to change myItem to Item, which represents the message the rule is acting on.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54








- Show quoted text -

Ok, I changed it to this, but it's still not doing anything. I have
to admit, I really don't understand the structure for Outlook VBA. I
can figure out Excel, of course the record macro feature helps me to
reverse engineer things, but I for some reason just can't grasp
Outlook.

Sub SaveAttachments(Item As Outlook.MailItem)

Dim myAttachments As Object

Set myAttachments = Item.Attachments
myAttachments(1).SaveAsFile "J:\Health Business Operations\MSO
\Blue Options\BOSCO Resource Management\Standard Reports\MSO Daily
Report\Current Report\" & "MCC Daily Performance Scorecard.mdi"
Item.Delete
End Sub
 
M

Murphybp2

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top