+ Reply to Thread
Results 1 to 13 of 13

Add multiple attachments to email

  1. #1
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Add multiple attachments to email

    Hi everyone,

    I have the following code:

    Please Login or Register  to view this content.
    As you can see I'm able to attach a 2nd document to the email I'm sending. What I'm trying to do is be able to attach more than 2, say up to 10or so. I worked out a code for this, but when I ran it File explorer would open 10 times regardless of whether you wanted to select a file or not.

    Any ideas how I can dynamically select attachments for the PA without having to be limited tby a maximum number?

    Thanks!!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Add multiple attachments to email

    If the user selects more than one file through GetOpenFilename then an array will be returned.

    You could then loop through that array to attach each of the selected file.

    First you would need to change the declaration of Attachment2 to Variant.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Add multiple attachments to email

    Hi Norie,

    I can certainly declare Attachment2 as Variant, but I'm not sure how I could loop the array as you suggested. Could you give me an example or show me how I could write it?

    Thanks,

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Add multiple attachments to email

    Something like this.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Add multiple attachments to email

    hi Norie,

    I tried your suggestion but it still only lets me attach a single additional document. Any ideas?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Add multiple attachments to email

    Oops, forgot you had to set the MultiSelect argument.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Add multiple attachments to email

    Hi everyone,

    Unfortunately I'm getting an error message using Norie's suggestion. I'm trying to have the user attach multiple documents into the same email.

    What I'm trying to do is have the ExtraAttachments.Show userform show up each time a document is attached so the user is asked whether they want to attach another document or not? Here's the code thus far:

    Please Login or Register  to view this content.
    Any ideas?

  8. #8
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Add multiple attachments to email

    Bump. Anyone?

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Add multiple attachments to email

    What exactly is the problem?

    By the way, do you really want to display the userform for each attachment?

    Would you consider a userform with a list of the attachments?

    That list would be in the form of a listbox which would be set up so each attachment had a checkbox next to it and the user would be able to select multiple attachments.

  10. #10
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Add multiple attachments to email

    hi Norie,

    The user needs to be able to select the attachments from anywhere they can get to in File explorer. Right now they can attach one and the email is sent. I need to get it so the user can select multiple attachments from various folders and have all of those sent in the email. That's really the final result. Any ideas?

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Add multiple attachments to email

    Did you try the code I posted in post #4 with the correction in post #6?

  12. #12
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Add multiple attachments to email

    Hi Norie,

    I certainly did. However, I got an error with the correct Attachment2 = Application.GetOpenFilename(MultiSelect:=True). Since the user may be attaching documents from various folders in the drive, I'm thinking that the userform would need to keep popping up until the user indicates there are no other attachments.

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Add multiple attachments to email

    What error did you get?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Email Multiple Attachments From Specified Path
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-05-2015, 01:23 PM
  2. Sending Email with Multiple Attachments from Excel
    By Lisa4legin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-29-2013, 03:24 PM
  3. [SOLVED] Looping Email- Multiple Attachments but I Only Want Selected Attachment
    By cschoyer in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-02-2012, 09:16 AM
  4. Email with multiple attachments
    By mcinnes01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-12-2011, 09:33 AM
  5. Can I save multiple email attachments using excel automatically?
    By ir26121973 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-18-2006, 03:00 PM

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