Tech Support Guy banner
Not open for further replies.
1 - 7 of 7 Posts

94 Posts
Discussion Starter · #1 ·

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.

Windows XP SP3
Outlook 2003

4,916 Posts
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.

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
1 - 7 of 7 Posts
Not open for further replies.