+ Reply to Thread
Results 1 to 12 of 12

need a macro that will send an email or emails from a list of emails

  1. #1
    Registered User
    Join Date
    04-21-2016
    Location
    UK
    MS-Off Ver
    Office 2016
    Posts
    14

    need a macro that will send an email or emails from a list of emails

    Column A = persons name
    column B = persons email address
    Column C = date email needs to be sent
    Column D = has email already been sent Y/N

    Can optionally create column E if it makes this macro easier = Does an email need to be sent today Y/N

    I will have a macro that continuously adds new addresses to the bottom of this list, it will also populate the date column at this point

    I want a macro that I can run daily that will check Columns C&D (or E) and send an email to that person if the date in column C is today (or earlier) AND the person hasn't already had an email sent to them.
    So the macro needs to also update Column D for each email it sends, might be helpful to have it add the date the email was sent in Column F as well.

    The macro can either email each person individually or BCC them all on to one email, I don't expect much more than 10-15 email addresses per day.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: need a macro that will send an email or emails from a list of emails

    Do you use MS Outlook as your email client?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: need a macro that will send an email or emails from a list of emails

    Give this a try

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by maniacb; 11-01-2020 at 06:01 PM. Reason: I assumed outlook

  4. #4
    Registered User
    Join Date
    04-21-2016
    Location
    UK
    MS-Off Ver
    Office 2016
    Posts
    14

    Re: need a macro that will send an email or emails from a list of emails

    Quote Originally Posted by maniacb View Post
    Give this a try

    Please Login or Register  to view this content.
    Thanks this is awesome
    works perfectly

    I had an error where the email had been entered incorrectly (and this could happen in future)
    Is there a way i could have it ignore bad emails, and maybe flag them as bad ?
    Last edited by MassiveJim; 11-01-2020 at 09:10 PM.

  5. #5
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: need a macro that will send an email or emails from a list of emails

    Here you go

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-21-2016
    Location
    UK
    MS-Off Ver
    Office 2016
    Posts
    14

    Re: need a macro that will send an email or emails from a list of emails

    Thanks,

    what criteria does the code use to determine if a cell is not an email ?

    I have tested this and purposely missed the ".co.uk" off the test email I was using, the macro runs ok when using .display. (doesn't flag the mail as bad)
    However when I switch to .Send those bad emails create an error and trigger the error handler.

    Error #-2147467259
    Outlook does not recognise one or more names.

  7. #7
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: need a macro that will send an email or emails from a list of emails

    The process to check emails was written by one of the gurus here. It definitely is not foolproof, as you have found.

  8. #8
    Registered User
    Join Date
    04-21-2016
    Location
    UK
    MS-Off Ver
    Office 2016
    Posts
    14

    Re: need a macro that will send an email or emails from a list of emails

    Quote Originally Posted by maniacb View Post
    The process to check emails was written by one of the gurus here. It definitely is not foolproof, as you have found.
    Is there anything that can be done in this case to have it ignore the error ?
    I am guessing not as its essentially an outlook error.

    I have put further checks in, earlier in the process to try and prevent bad email addresses making it through but that will not be infallible.

  9. #9
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: need a macro that will send an email or emails from a list of emails

    Try this approach. Instead of notifying you of the error in VBA, this process will just continue sending emails, but you won't know that their is a bad email if the internal check doesn't catch the error. I'm assuming the email error you received is generated through VBA, but if it is generated by Outlook, we may be out of luck.

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    04-21-2016
    Location
    UK
    MS-Off Ver
    Office 2016
    Posts
    14

    Re: need a macro that will send an email or emails from a list of emails

    Quote Originally Posted by maniacb View Post
    Try this approach. Instead of notifying you of the error in VBA, this process will just continue sending emails, but you won't know that their is a bad email if the internal check doesn't catch the error. I'm assuming the email error you received is generated through VBA, but if it is generated by Outlook, we may be out of luck.

    Please Login or Register  to view this content.
    This does exactly what you said.
    If I check the sent items the bad email does not show as a sent item, and it does not get flagged in excel.

    I assume from your post that there is no way to work around this ?


    Regards
    James

  11. #11
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: need a macro that will send an email or emails from a list of emails

    It sounds like the VBA produced the error code. Let's try the following approach to annotate the bad email in your spreadsheet.

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    04-21-2016
    Location
    UK
    MS-Off Ver
    Office 2016
    Posts
    14

    Re: need a macro that will send an email or emails from a list of emails

    That produces the same result.

+ 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 emails with different attachments and table in the email.
    By aashish.shetty in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2022, 05:36 AM
  2. VBA macro to send emails to list of recipients.
    By GNTS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-25-2017, 10:06 PM
  3. Excel vba to auto-send customer emails (duplicate emails issue)
    By nadz84 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-29-2015, 10:08 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. [SOLVED] Macro To Send Emails with PDF: Multiple Emails and PDF's
    By totoga12 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 03-19-2014, 06:13 PM
  6. Sending macro emails using excel: Send emails with their passwords.
    By loveisblind in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2009, 03:16 PM
  7. Send an email to a list of emails in a worksheet
    By cexarsiado in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 08-25-2006, 03:30 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