1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Outlook 2003 automatically save attachments

Discussion in 'Business Applications' started by TeDiouSish, Jan 5, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. TeDiouSish

    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
     
  2. Rollin_Again

    Rollin_Again

    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
     
  3. TeDiouSish

    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.
     
  4. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    I'll work on this for you today.

    Rollin
     
  5. TeDiouSish

    TeDiouSish Thread Starter

    Joined:
    Jan 5, 2011
    Messages:
    94
    Thank you, very much! It's appreciated.
     
  6. Rollin_Again

    Rollin_Again

    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
     
  7. TeDiouSish

    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!
     
  8. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/972897

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice