Solved: Outlook 2003 automatically save attachments

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

TeDiouSish

Thread Starter
Joined
Jan 5, 2011
Messages
94
Hi,

I've searched through various sites, but I have yet to find a way to make this possible..

What I would like to accomplish:
When an email is received and if it has a PDF attached, and is from a certain sender, that PDF is automatically saved unto the drive. (Not in the outlook folders)

How would I do that?

I found VBA scripts, but I didn't know how to go about using them. This is one of the links I found.
http://www.codeforexcelandoutlook.c...utlook-2003-e-mail-attachments-automatically/

Windows XP SP3
Outlook 2003
 
Joined
Sep 4, 2003
Messages
4,912
You can use a mail rule to trigger the macro. Are you familiar with setting up rules? I can help you with the code to save the attachment.

Rollin
 

TeDiouSish

Thread Starter
Joined
Jan 5, 2011
Messages
94
I am familiar with the rules, only slightly, but I know how to set them up.

Help would be greatly appreciated.
 
Joined
Sep 4, 2003
Messages
4,912
Here are the steps to take

Open Outlook and press ALT + F11 to open the VB editor.

On the left hand side of the editor you will see your project explorer window. Expand the objects in the project by clicking the little plus symbol next to the project name until you see an object called "ThisOutlookSessioin." Once found RIGHT click on "ThisOutlookSession" and choose VIEW CODE and copy and paste the code below into the empty code module.

Now close the code window and set up your rule by clicking TOOLS >> RULES AND ALERTS and selecting the option NEW RULE

After selecting NEW RULE choose the option to start with a blank rule and then select the option to check messages when they arrive.

Next choose the condtion for the rule to fire >> FROM PEOPLE OR DISTRIBUTION LIST and then set the value for the sender names/email address by clicking the link in the rule description window at the bottom. After setting the value click NEXT

Now select the action to take when a message is received from this specific person >> RUN A SCRIPT

Next set the script name to run by clicking the "script" link in the rule description window at the bottom. Here is where you select the macro we copied and pasted earlier. In my example I named it "SaveAttachments"

After selecting the correct script to run click FINISH and you should be all set. Just change the red highlighted value in the script to reflect the correct save location.

Code:
Sub SaveAttachments(myMail As MailItem)
Dim vFrom As String, vSubject As String
Dim vFile As Attachment
 
vFrom = myMail.ReceivedByName
vSubject = myMail.Subject
 
If myMail.Attachments.Count > 0 Then
        For i = 1 To myMail.Attachments.Count
            Set vFile = myMail.Attachments(i)
            If LCase(vFile.FileName) Like "*.pdf" Then
            vFile.SaveAsFile "[COLOR="Red"]C:\Test[/COLOR]\" & vFile.FileName
            End If
        Next i
End If
 

Set myMail = Nothing
Set vFile = Nothing
End Sub
Rollin
 

TeDiouSish

Thread Starter
Joined
Jan 5, 2011
Messages
94
Hi,

Thank you for taking the time. It works!

I had to create a folder named "test" on C:\. But I'll be sure to edit that.

Cheers!
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Top