Sent mass email based on cell values

floggingmolly

Board Regular
Joined
Sep 14, 2019
Messages
167
Office Version
  1. 365
Platform
  1. Windows
I have a list of employee ID's in column A. In column B is either YES or NO based on a vlookup verifying if they entered data in a schedule sheet. I need to send an email to any employee ID with a NO in column B. I would like to send them all in one email as a bcc since there are 180 employees. Is this possible using vba? I was able to send an email but only to one at a time. Any help would be greatly appreciated.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Let's start with this:

Code:
Sub Send_Mass_Email()
  Dim i As Long, dam As Object
  For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
    If Cells(i, "B").Value = "No" Then
      Set dam = CreateObject("outlook.application").createitem(0)
      dam.To = "email@yahoo.com"
      dam.Bcc = "mail2@gmail.com; mail3@gmail.com"
      dam.Subject = "subject.."
      dam.Body = "body ..."
      dam.Display 'use .Send to send
    End If
  Next
  MsgBox "Sent"
End Sub
 
Upvote 0
Thanks for the quick reply. Here's where I am stuck. Column A has the employee ID #. Column B has YES or NO. Column C has the employees email address. When column B is a NO I would like to generate a mass email to all the addresses that have a NO. Is there a way to automatically enter all NO emails into one email? In the code example above the emails are already in the code. I hope this makes sense.
 
Upvote 0
Thanks for the quick reply. Here's where I am stuck. Column A has the employee ID #. Column B has YES or NO. Column C has the employees email address. When column B is a NO I would like to generate a mass email to all the addresses that have a NO. Is there a way to automatically enter all NO emails into one email? In the code example above the emails are already in the code. I hope this makes sense.


Try this

Code:
Sub Send_Mass_Email()
  Dim i As Long, dam As Object, wMail As String
  For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
    If Cells(i, "B").Value = "No" Then wMail = wMail & Cells(i, "C").Value & "; "
  Next
  Set dam = CreateObject("outlook.application").createitem(0)
  dam.To = "email@yahoo.com"
[COLOR=#0000ff]  dam.Bcc = wMail[/COLOR]
  dam.Subject = "subject.."
  dam.Body = "body ..."
  dam.Display 'use .Send to send
  MsgBox "Sent"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,707
Messages
6,174,000
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top