Send Emails Using VBA From Excel Sheet With Multiple Recipients

    1. Home
    2. Questions
    3. Tags
    4. Users
    5. Companies
    6. Jobs
    7. Discussions
    8. Collectives
    9. Communities for your favorite technologies. Explore all Collectives

  1. Teams

    Ask questions, find answers and collaborate at work with Stack Overflow for Teams.

    Try Teams for free Explore Teams
  2. Teams
  3. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams Send emails using VBA from Excel sheet with multiple recipients - pull in date and attachment Ask Question Asked 2 years, 5 months ago Modified 1 year, 11 months ago Viewed 3k times 0

I am using VBA code to send emails from an Excel sheet:

I use code to generate a separate email for each email address in Column C with a file attached.

I am looking to add code to:

  1. Pull in the date from column D to the body of the email. I have put in the code for the body of the email where I want the date to go. How do I get the date for each email row by row.
  2. Attach an additional file to the email IF there is a link in column E. This would be in addition to the one already in the code.

Each row in the Excel sheet should generate a separate email using the email address in column C, date in column D and attachment in column E.

Share Improve this question Follow edited Dec 19, 2022 at 23:46 Doors asked Jun 22, 2022 at 20:28 Doors's user avatar DoorsDoors 51 silver badge3 bronze badges 1
  • If you study the code you found, you can figure this out. – findwindow Commented Jun 22, 2022 at 20:31
Add a comment |

1 Answer 1

Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 0

assume that the rest of the code works, just update the with-block to:

With MItem .To = sourceWorksheet.Cells(RowIndex, 3).Value .Subject = "Subject Here" If Cells(RowIndex, 5) <> "" Then .Attachments.Add Cells(RowIndex, 5).Value If Cells(RowIndex, 6) <> "" Then .Attachments.Add Cells(RowIndex, 6).Value .HTMLBody = "<font face = ""Calibri(Body)"" font size=""3"" color=""black""><p>Good afternoon, </p>" & _ "<p><strong>Please review the attached and return by " & Cells(RowIndex, 4) & ". </strong> </p></font>" & .HTMLBody .Display End With Share Improve this answer Follow answered Jun 23, 2022 at 9:18 Loveb's user avatar LovebLoveb 3251 silver badge10 bronze badges 2
  • Thank you so much! I have one more question - the code is generating an email when there is no email address in column C. I want it to skip over any row with no email address - can you advise on code to add? I tried adding If Cells(RowIndex, 3) <> "" before .To but it did not work. – Doors Commented Jun 27, 2022 at 16:11
  • Hi Sharon, just add if sourceWorksheet.Cells(RowIndex, 3) <> "" then before With MItem and End if after End With – Loveb Commented Jun 30, 2022 at 9:29
Add a comment |

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid …

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Draft saved Draft discarded

Sign up or log in

Sign up using Google Sign up using Email and Password Submit

Post as a guest

Name Email

Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.

  • The Overflow Blog
  • The open-source ecosystem built to reduce tech debt
  • Featured on Meta
  • More network sites to see advertising test
  • We’re (finally!) going to the cloud!
  • Call for testers for an early access release of a Stack Overflow extension...
13 How to send email to multiple recipients with addresses stored in Excel? 6 Excel VBA Sending emails with multiple attachements 3 Sending multiple attachments from excel sheet with VBA 1 Send single email to recipients with multiple messages 2 How to send mail to multiple recipients in outlook in vba 1 Sending Outlook Email with multiple recipients from Excel file 2 Send Outlook email with attachment using Excel VBA 1 VBA - Sending an Outlook Email to unknown number of recipients 0 multiple recipients in email but send mail through loop 2 Sending multiple emails using data from excel cells using VBA

Hot Network Questions

  • Generate A Point Inside An Arbitrary Concave Polygon
  • Could Dukkha be interpeted as anxiety?
  • The best design I could think up uses 2 PWM lines and a ground, how does this device do it with only 2 wires?
  • Is it ever possible that the object is moving with a velocity such that its rate of change of speed is not constant but acceleration is constant?
  • Phase cancellation in beams of light- edited
  • Why is the kabalat hatorah at Purim needed?
  • Why are there no monadic operations in std::expected<void, Error>
  • Is there a better CR equivalent?
  • Manga (possibly a manhua) where the main character travels up a tower. He meets a bunny every time he goes up a stage
  • How to assess differences between tensor product smooths?
  • Spanish train pre-ordered meals and special diets
  • Why is \cs_generate_variant:Nn \clist_put_right:Nn { Nc } deprecated when the recommended \clist_put_right:Nv doesn't give the expected result?
  • routing LAN connections among clients on same ISP router device
  • Switched to Gas from Induction, hate it, is it the range?
  • A place somewhere in Europe
  • Employer changing resignation date to avoid holiday day pay
  • Procrastination of cases requiring concentration
  • Can A Fairy Fly With A Magical Breastplate Weighing 10 lbs?
  • What is the proper interpretation of the output 'HF' energy of a ground-state Gaussian 16 calculation using the opt keyword (B3LYP)?
  • How to retort when somebody says something you already know?
  • Difference between sostenible and sustentable
  • Distinct sums and products of adjacent numbers
  • Heap with Non Clustered Index vs. Non-Sequential Clustered Index
  • Readability and error handling improvements for Python web scraping class
more hot questions Question feed Subscribe to RSS Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-vb

Từ khóa » Visual Basic Code To Send Email From Excel