+ Reply to Thread
Results 1 to 8 of 8

Send emails to different people each containing different content in the body based on cel

  1. #1
    Registered User
    Join Date
    04-03-2012
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Send emails to different people each containing different content in the body based on cel

    Hello all,

    I am still very new to VBA, and the Mail function is confusing me to no end. What I'm trying to do is to send a list of emails to emails listed in column A (A1-A30) each containing different information in the body of the email based on whats in other cells (or sheets in the workbook)

    so I want to send an email to the address listed in A1 containing, in the body of the email, content from cells B1-E1.

    and repeat for subsequent cells.

    The email program I will be using is outlook 2010, but is it possible to direct emails to pop up using whatever the default windows email client is for that computer?

    Any help is really appreciated!

    thanks a ton,
    Drake

  2. #2
    Registered User
    Join Date
    04-03-2012
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Send emails to different people each containing different content in the body based on

    I found a sheet that works well for most of what I need! however, I barely understand any of the code, and theres one thing that I need it to do in addition to what its already doing:

    I have a third sheet that will have the same list of names as the emails, with stats next to each name (same line) - I need each email that is selected to also send only the stats from that person name in the body in addition to whats written in the text box.

    Thank you to jaslake for writing the original code! (http://www.excelforum.com/excel-prog...outlook-2.html)

    emailing.xlsm

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send emails to different people each containing different content in the body based on

    Hi Drake2300

    You'll need to redesign your Sheet Stats to add unique identifiers. You may well have two or more Students with the same first name. Do you use Student ID"S?

    Please share YOUR file...not someone else's.
    John

    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.

  4. #4
    Registered User
    Join Date
    04-03-2012
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Send emails to different people each containing different content in the body based on

    Quote Originally Posted by jaslake View Post
    Hi Drake2300

    You'll need to redesign your Sheet Stats to add unique identifiers. You may well have two or more Students with the same first name. Do you use Student ID"S?

    Please share YOUR file...not someone else's.
    In this case the Email will be unique for every person - emails cannot be duplicated in our system, the Student # on page one will also be unique.

    Ive tinkered with the sheet code for the above sheet to suite my needs, but i'm still not able to get it to do what i want it to do, and I'm not sure what i'm doing wrong.

    I've tried using Application.WorksheetFunction.VLookup(E_name, Sheet2.Range("C2:J36"), 2, False) from within the 'Body' section of the Email code:

    .Body = ws.OLEObjects("TextBox2").Object.Text & "<BR>" & _
    Application.WorksheetFunction.VLookup(ws.Cells(cel.Row, "C").Value, Sheet2.Range("C2:J36"), 2, False)

    That didnt seem to work, but when I change the number 2 to a 1 I get an email address added to the body.

    in the below sheet, I tried to reference individual cells, as I noticed the code cycles columns (at least I think it does) - but that doesn't seem to work either

    in sheet 3 I've given a basic example of what I would like each email to look like when this is all said and done.

    I think I'm missing something important with formatting here, can you suggest anything for me?emailing.xlsm

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send emails to different people each containing different content in the body based on

    Hi Drake2300

    I'm not at all certain what you're attempting to do...try the attached.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-03-2012
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Send emails to different people each containing different content in the body based on

    You are a genious sir. This is exactly what I needed - i'm seeing some changes in the VBA - is this the only place you changed?

    .htmlbody = ws.OLEObjects("TextBox2").Object.Text & "<BR><BR>" & _
    RangetoHTML(mailRng)
    ' .Body = ws.OLEObjects("TextBox2").Object.Text & "<BR>" & _
    ' ws.Cells(cel.Row, "D").Text & "<BR>" & _
    ' ws.Cells(cel.Row, "E").Text & "<BR>" & _
    ' ws.Cells(cel.Row, "F").Text & "<BR>" & _
    ' ws.Cells(cel.Row, "G").Text & "<BR>" & _
    ' ws.Cells(cel.Row, "H").Text & "<BR>" & _
    ' ws.Cells(cel.Row, "I").Text & "<BR>" & _
    ' ws.Cells(cel.Row, "J").Text

    does this mean I was on the right track? it's the conversion to HTML that I was missing?

    I'm still learning, so I really appreciate this help, thank you! I will mark this as solved.

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send emails to different people each containing different content in the body based on

    Hi Drake2300

    I also made some changes here to capture the Range of Cells to include in the Body of the Email
    Please Login or Register  to view this content.
    and here for Column Reference of Attachments (if any)...
    Please Login or Register  to view this content.
    And of course, Ron de Bruin's Function RangetoHTML(rng As Range)...
    Please Login or Register  to view this content.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send emails to different people each containing different content in the body based on

    You're welcome...glad I could help. Thanks for the Rep.

+ 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. Macro to send automatically emails to different people with attachments
    By Dr.Tenma in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2015, 08:38 AM
  2. Macro to send different emails to different people with attachment
    By Dr.Tenma in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-07-2015, 08:15 AM
  3. Replies: 2
    Last Post: 12-19-2014, 11:28 AM
  4. Send Emails once expiry date is reached, and generate report based on emails sent
    By demonicscorpion in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2014, 05:36 AM
  5. Users send emails to themselves and it's delivered to a group of people?
    By MetroBOS in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 09-19-2014, 02:53 PM
  6. Help needed to Send Emails with atachment and company logos on Email Body
    By aukhan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-11-2013, 11:46 PM
  7. Find totals and send emails to different people
    By Nonboff in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-08-2009, 06:56 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