+ Reply to Thread
Results 1 to 10 of 10

Sending Email with Multiple Attachments from Excel

  1. #1
    Registered User
    Join Date
    03-17-2012
    Location
    Mississauga,Ontario
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    75

    Sending Email with Multiple Attachments from Excel

    Hi,

    I got this very good Macro from some contributor on this site Called Callmailer which sends emals from Excel. However this particualr macro only supports an individual File attachement . I am trying to modify this code to include multiple attachements. I tried to use a comma but I guess that doesnt work. the file exam.xls is the list of the attachments I need to sent .

    Also is there a modification of this code somewhere ??

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Sending Email with Multiple Attachments from Excel

    It appears that you can have multiple attachments by just initiating another .add to the .attachment. A simple version could look like this:
    Please Login or Register  to view this content.
    Where:
    Please Login or Register  to view this content.
    I've never done it, but you could likely loop through the range of attachments if they are all in one folder and append the file names to the path with a strSeperator = ";".
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  3. #3
    Registered User
    Join Date
    03-17-2012
    Location
    Mississauga,Ontario
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    75

    Re: Sending Email with Multiple Attachments from Excel

    I've never done it, but you could likely loop through the range of attachments if they are all in one folder and append the file names to the path with a strSeperator = ";".
    Can some one help me out with How I can incorporate this into the Code above?

  4. #4
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Sending Email with Multiple Attachments from Excel

    Replace this block of code:
    Please Login or Register  to view this content.
    with:
    Please Login or Register  to view this content.
    Then pass multiple attachment file names (inc. full paths) in the strAttachmentPath parameter as a comma-separated string which you create with code, for example "c:\excel\book1.xls,c:\data.dat,c:\temp\file.txt".
    Last edited by Chippy; 04-24-2012 at 05:20 PM.
    Post responsibly. Search for excelforum.com

  5. #5
    Registered User
    Join Date
    03-17-2012
    Location
    Mississauga,Ontario
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    75

    Re: Sending Email with Multiple Attachments from Excel

    Then pass multiple attachment file names (inc. full paths) in the strAttachmentPath parameter as a comma-separated string which you create with code, for example "c:\excel\book1.xls,c:\data.dat,c:\temp\file.txt".
    thanks ,so based on the sheet attached ,cant I just list out the files like filea.html, fileb.xls. I have to build a comma separated string ?

  6. #6
    Registered User
    Join Date
    03-17-2012
    Location
    Mississauga,Ontario
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    75

    Re: Sending Email with Multiple Attachments from Excel

    Hi ,

    please see attached sheet , I created separate columns for the files I want to attach however I keep getting "cannot find the file" when I am seeing it in the folder.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Sending Email with Multiple Attachments from Excel

    You may be seeing the file, but more importantly what is the code seeing? Try stepping through it with F8 in VB editor and investigate what is happening.

  8. #8
    Registered User
    Join Date
    03-17-2012
    Location
    Mississauga,Ontario
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    75

    Re: Sending Email with Multiple Attachments from Excel

    Hi,

    Actually I see it in the folder where it is picking it from--its not getting attached .. so the code seems incorrect.--that's what I was trying to say.

  9. #9
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Sending Email with Multiple Attachments from Excel

    If the code seems incorrect, use F8 as I suggested to investigate what it's doing and determine how it's incorrect.

    Looking at your workbook, you need to include the file extension in each file name in column E, F and G. Therefore BOL943034 in E2 should be BOL943034.xls, or BOL943034.txt, or whatever the file extension is.

    In the code,
    Please Login or Register  to view this content.
    is looking in column 6 (F), however your file name attachment list is in column H, therefore change this to:
    Please Login or Register  to view this content.
    Using column letters like this instead of column numbers makes the code easier to understand.

  10. #10
    Registered User
    Join Date
    03-29-2013
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Sending Email with Multiple Attachments from Excel

    Would anyone be able to tell me if this code works with PDF's?

    if it does, could anyone point me in the direction as to why i'm getting this error:

    "Path does not exist. Make sure the path is correct."
    hightlighed in yellow: Set objOutlookAttach = .Attachments.Add(strAttachmentPath)

    the excel sheet has the path located to: C:\Documents and Settings\zl1\Desktop\test
    the excel sheet has the file name as: LB7test.pdf

    any help would be appreciated

    ________________
    edit:

    Actually, figured it out after the rest of this tread loaded on my slow computer, answer was right above. thanks!
    Last edited by zl1; 03-29-2013 at 03:27 PM. Reason: figured out

+ 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