+ Reply to Thread
Results 1 to 7 of 7

VBA Code to email multiple people and code to go to the next email if error occurs

  1. #1
    Registered User
    Join Date
    12-24-2017
    Location
    houston
    MS-Off Ver
    2010
    Posts
    6

    VBA Code to email multiple people and code to go to the next email if error occurs

    Hi Gurus! I have a code that sends out multiple emails to people in one swoop! it is really awesome actually. I need help getting this code to include the following:
    1. email multiple people
    2. Go to the next email if error occurs & show a message at end of code to inform user of skipped people

    Please let me know if you are willing to help.

    Pmeltzers!

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

    Re: VBA Code to email multiple people and code to go to the next email if error occurs

    Does the current code only sent emails to individual recipients?

    When would you want to sent emails to multiple recipients?

    What error(s) would you be expecting to encounter?
    If posting code please use code tags, see here.

  3. #3
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA Code to email multiple people and code to go to the next email if error occurs

    If using outlook, you could create a email list in a column in separate sheet and use code to add those email addresses to the email. If there is an error, such as an email wasn't sent, you should automatically get an email notification that it didn't send.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  4. #4
    Registered User
    Join Date
    12-24-2017
    Location
    houston
    MS-Off Ver
    2010
    Posts
    6

    Re: VBA Code to email multiple people and code to go to the next email if error occurs

    I'd like for it to send to multiple recipients in different instances.
    A recipient may or may not have multiple emails so it is very random. I need for it to tell me if there is an error (if this is true) that it is due to the email address not being valid...

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2405
    Posts
    24,995

    Re: VBA Code to email multiple people and code to go to the next email if error occurs

    Quote Originally Posted by pmeltzers
    I have a code that sends out multiple emails to people in one swoop! it is really awesome actually.
    Please post awesome code as a starting point for discussion.

    Quote Originally Posted by pmeltzers View Post
    I need for it to tell me if there is an error (if this is true) that it is due to the email address not being valid...
    VBA can determine if the email address is well-formed before trying to send (e.g., using fred.gmail.com as an email address). What do you mean by "not being valid"?

    VBA code cannot determine if an email fails to be delivered. If an email address is not valid there are multiple things that can happen, none of which is a synchronous response back to the VBA process. Here are the most common:
    • Invalid domain name. The sending SMTP or Exchange server will reject the outgoing email. You may get a bounce notice at your client.
    • Invalid username. The receiving SMTP server will reject the incoming email. You may get a bounce notice at your client, but many servers will not report non-existent email addresses.
    • Mail can't be delivered (e.g., full mailbox). The receiving SMTP server will reject the incoming email. You may get a bounce notice at your client, but many servers will not report undeliverable email.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2405
    Posts
    24,995

    Re: VBA Code to email multiple people and code to go to the next email if error occurs

    I would like to amend my answer. It would be possible to set up a telnet session from VBA that would connect to the mail domain's SMTP server and parse the response to see if the email address exists. Here is a detailed description of the telnet session and here is a description of how to implement a telnet session in VBA. I have never done the latter so can't offer a completed solution.

  7. #7
    Registered User
    Join Date
    12-24-2017
    Location
    houston
    MS-Off Ver
    2010
    Posts
    6

    Re: VBA Code to email multiple people and code to go to the next email if error occurs

    Come to find out: In order to enable the auto send instead of additional step to click on each popped up email are to only have 1 recipient email address for each vendor code and the code being Olmail.Send instead of OImail.display

+ 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. Code to send email with table on the email body via gmail
    By ivhee00 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-19-2017, 12:24 AM
  2. Change VBA to allow email code to bring up outlook email before sending it
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2015, 02:33 AM
  3. VBA Code to Auto intialsend email & reminder email based on cell value
    By swk8429 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-16-2015, 06:15 AM
  4. Code to Email Specific People Based on ComboBox Selection
    By esanvilla in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2015, 10:08 AM
  5. VBA code to send email to the people whose email address is in the Access table
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-30-2014, 05:11 AM
  6. [SOLVED] Why do I get this error on code from Mr. Debruin's email code?
    By rkjudy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-14-2014, 05:01 PM
  7. Excel code to email whats in the spreadsheet in the body of email
    By Kain93 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2012, 09:55 AM

Tags for this Thread

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