+ Reply to Thread
Results 1 to 12 of 12

How to add an email attachement to VBA Mass Email by referencing file name in column

  1. #1
    Registered User
    Join Date
    04-08-2014
    Location
    City
    MS-Off Ver
    Excel 2007
    Posts
    8

    How to add an email attachement to VBA Mass Email by referencing file name in column

    Hi,

    I'm trying to create a macro in excel that will send an email via Outlook with 2 attachments. 1 of the attachments will be unique to the individual and I want to be able to pick up the file name by referencing the file name column in excel e.g. .Attachments.Add ("D:\File\Document2_FullName.pdf") - Record 1 is John Smith so the file link will be "D:\File\Document2_JohnSmith.pdf". A loop will also be required so that it can move to the next record.

    This is what I have so far -

    Please Login or Register  to view this content.
    Any assistance will be greatly appreciated.

    Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    Hi XLC88, and welcome to the forums.

    Firstly, take a look at the forum rules, this will assist you to understand what is considered "good form" when requesting assistance (and NO, you havent transgressed with your post so don't panic)

    Secondly, it is always worthwhile to post a sample workbook clearly showing the inputs and the expected results. Sadly the volunteers on this forum generally all have "day jobs" and will unfortunately often bypass a request if it means they need to construct a workbook that may or may not bear any resemblance to yours.

    An added bonus, you often get working code back in your workbook to subsequent development.

    In terms of email processing from excel, the wonderful resource available from Ron de Bruin (easily googled) has saved my bacon a few times already.

    Post a workbook and I will take a look for you (unless another solution is posted before I get there )

    Again, welcome to the forum.

    Jmac

  3. #3
    Registered User
    Join Date
    04-08-2014
    Location
    City
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    Hi Jmac,

    Thanks for replying to my query.

    I have attached a sample for your reference.

    I need to send an email to each record with 2 attachments. For 1 of the attachments, the file path will be the same for all (D:\Test\), however the document name will be "First_Lastname.PDF" - please see Col F for example.

    Any assistance will be greatly appreciated.

    Attachment 310329

  4. #4
    Registered User
    Join Date
    04-08-2014
    Location
    City
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    Apologies, please refer to Col E for example.

  5. #5
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    Sorry, I get an error when trying to access the attachment in your post.

    Did you use the "Go Advanced" button at the bottom of the posting screen, manage attachments option??

    Jmac

  6. #6
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    one more quick question, do you have control over the workbook, that is could you add a new column if needed??

  7. #7
    Registered User
    Join Date
    04-08-2014
    Location
    City
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    I've attached the worksheet =Test.xlsm. I've played around with the macro again and I was able to get the 2 attachments to reference the file name in Col E and F but I'm having troubles looping the macro to create a new email for the next record -

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-08-2014
    Location
    City
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    Yes, I have control over the workbook if new columns are required

  9. #9
    Registered User
    Join Date
    04-08-2014
    Location
    City
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    Sorry for the spam but I got the following code to work but when the 2nd email is created, the attachments from the previous record is attached with the email in additional to their corrected files-

    Example -
    John Smith - 2 Attachments: John_Smith.pdf and Doc1
    Jane Doe - 4 attachments: John_Smith.pdf and Doc1 plus Jane_Doe.pdf and Doc 2
    Jack Lim - 6 attachments: John_Smith.pdf and Doc1 plus Jane_Doe.pdf and Doc 2 plus Jack_Lim.pdf and Doc 1

    The correct attachments should be -

    John Smith - 2 Attachments: John_Smith.pdf and Doc1
    Jane Doe - 2 attachments: Jane_Doe.pdf and Doc 2
    Jack Lim - 2 attachments: Jack_Lim.pdf and Doc 1

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    Good morning,

    Take a look at the code in the attached, it does appear to work with the test data in the spreadsheet.

    It may not be the most wonderful solution technically or in terms of speed but it does seem to work

    You will need to un-comment your path details and delete mine of course and eventually change the .Display to a .send

    XCL88.xlsm

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  11. #11
    Registered User
    Join Date
    04-08-2014
    Location
    City
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    works like a charm! thanks so much for your help!

  12. #12
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: How to add an email attachement to VBA Mass Email by referencing file name in column

    you are welcome, and thanks for the rep

    enjoy your forum experiences

+ 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. Mass email a column of email addresses?
    By bmblack in forum Excel General
    Replies: 3
    Last Post: 09-30-2015, 03:06 PM
  2. Automatic Email and Attachement
    By Phil_Lloyd_1979 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2014, 12:13 PM
  3. HELP PLease:Mass Email from addresses in excel file
    By knevil in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-06-2013, 05:54 PM
  4. email - Attachement of files
    By Canuckbulldog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-08-2007, 02:11 PM
  5. Email addresses in Excel need to format for mass email
    By Boomer in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-09-2006, 08:50 AM

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