+ Reply to Thread
Results 1 to 10 of 10

Download attachment and rename with subject line

  1. #1
    Registered User
    Join Date
    10-21-2009
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    59

    Download attachment and rename with subject line

    Dear Gurus

    I need urgent help, I have below macro to download attachment from email. But I need little amendment. I want to rename every attachment (in every email) with its subject line. My every email in outlook has only one attachment. I can't figure out how to do this trick.

    Thanks in Advance

    I am using this code to download all attachments

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 12-18-2010 at 11:15 AM. Reason: added tags ... title edited: "Urgent Help!. " removed

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Urgent Help!. Download attachment and rename with subject line

    Try

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    10-21-2009
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: Urgent Help!. Download attachment and rename with subject line

    Dear Mrice

    Thanks for quick reply :-) it worked perfectly.

    Thanks a lot.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    21,528

    Re: Urgent Help!. Download attachment and rename with subject line

    @ali84pk - glad you have a resolution - going forward please be sure to familiarise yourself with the Forum Rules re: Code Tags, Titles etc...

  5. #5
    Registered User
    Join Date
    04-25-2012
    Location
    Alaska
    MS-Off Ver
    Microsoft Office 2007
    Posts
    1

    Re: Urgent Help!. Download attachment and rename with subject line

    Quote Originally Posted by mrice View Post
    Try

    Please Login or Register  to view this content.
    Hello,
    So where does this fit in the code above?

  6. #6
    Registered User
    Join Date
    10-21-2009
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: Urgent Help!. Download attachment and rename with subject line

    Quote Originally Posted by nika81 View Post
    Hello,
    So where does this fit in the code above?


    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-04-2012
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Download attachment and rename with subject line

    No to revive this old thread, but I'm having issues running this with "MyMail As MailItem" between the brackets: Sub Download_contracts(MyMail As MailItem)

    I'm unable to step through the macro or see it in the "Alt F8" window. If I remove it from the brackets and declare the variable separately I get an error here after stepping through it: strID = MyMail.EntryID

    "Object variable or With block variable not set".

    Am I missing something? I do have my outlook references setup.

  8. #8
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,164

    Re: Download attachment and rename with subject line

    rtnlsltn,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  9. #9
    Registered User
    Join Date
    03-10-2015
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    1

    Re: Download attachment and rename with subject line

    Hi,

    I have used the following script to achieve what you are doing BUT it only deals with 1 attachment per mail - either it doesnt save the second (and subsequent) attachments or else it saves them and overwrites them. Any ideas?
    Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
    Dim objAtt As Outlook.Attachment
    Dim saveFolder As String
    saveFolder = "C:\Users\chrisf\Desktop\Image Test\"
    MSN = Trim(itm.Subject)

    For Each objAtt In itm.Attachments
    If objAtt.FileName <> "image001.gif" Then
    objAtt.SaveAsFile saveFolder & "\" & itm.Subject & ".JPG"
    End If

    Set objAtt = Nothing
    Next
    End Sub

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel 2010
    Posts
    1,998

    Re: Download attachment and rename with subject line

    hi,
    Please open yr own thread and ask for help!
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1