A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Help with Saving Attachment with VBA from Rules



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 20th 07, 01:18 PM posted to microsoft.public.outlook.program_vba
Murphybp2
external usenet poster
 
Posts: 26
Default Help with Saving Attachment with VBA from Rules

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

Ads
  #2  
Old August 20th 07, 04:36 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Help with Saving Attachment with VBA from Rules

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


"Murphybp2" wrote in message ups.com...
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

  #3  
Old August 20th 07, 06:21 PM posted to microsoft.public.outlook.program_vba
Murphybp2
external usenet poster
 
Posts: 26
Default Help with Saving Attachment with VBA from Rules

On Aug 20, 11:36 am, "Sue Mosher [MVP-Outlook]"
wrote:
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



"Murphybp2" wrote in oglegroups.com...
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- Hide quoted text -


- 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

  #4  
Old August 20th 07, 09:17 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Help with Saving Attachment with VBA from Rules

What condition are you using to make this rule fire? What happens when you add a breakpoint? Does any Outlook VBA code run at all? Check the basics: http://outlookcode.com/article.aspx?id=49

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


"Murphybp2" wrote in message oups.com...
On Aug 20, 11:36 am, "Sue Mosher [MVP-Outlook]"
wrote:
You need to change myItem to Item, which represents the message the rule is acting on.

"Murphybp2" wrote in oglegroups.com...
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- Hide quoted text -


- 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

  #5  
Old August 21st 07, 02:16 PM posted to microsoft.public.outlook.program_vba
Murphybp2
external usenet poster
 
Posts: 26
Default Help with Saving Attachment with VBA from Rules

On Aug 20, 4:17 pm, "Sue Mosher [MVP-Outlook]"
wrote:
What condition are you using to make this rule fire? What happens when you add a breakpoint? Does any Outlook VBA code run at all? Check the basics:http://outlookcode.com/article.aspx?id=49

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



"Murphybp2" wrote in ooglegroups.com...
On Aug 20, 11:36 am, "Sue Mosher [MVP-Outlook]"
wrote:
You need to change myItem to Item, which represents the message the rule is acting on.


"Murphybp2" wrote in oglegroups.com...
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- Hide quoted text -


- 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- Hide quoted text -


- Show quoted text -


It appears to be working now. Not sure why it wasn't working
yesterday. Thanks for the help.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
saving a distribution list that is attachment in e-mail SITCFanTN Outlook - Using Contacts 7 April 19th 07 05:23 PM
how to change the location of saving attachment permanenntly Mohammad Outlook - Installation 1 January 26th 07 10:18 PM
Update for new Daylight Saving rules in US Stephen Sentoff Outlook - Calandaring 1 November 12th 06 01:19 AM
Saving attachments to disk using rules? Matt Outlook and VBA 1 May 26th 06 12:51 PM
saving email without attachment Happy Outlook Express 3 January 24th 06 05:34 PM


All times are GMT +1. The time now is 06:10 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.