RedOctoberKnight
Board Regular
- Joined
- Nov 16, 2015
- Messages
- 153
- Office Version
- 2016
- Platform
- Windows
Good Evening All,
I currently have a workbook that I use to send out overdue training assignments. I have a daily training report emailed to me. The overdue training assignments are in column A with the person's last name in B, first name in C, and their email address is in column D. I currently copy and paste columns B-D into my "email generator" that basically removes all the duplicate email addresses and then sends a generic " you have overdue training email"
What I would like it to do is send a single email to each individual with a list of the overdue training subjects in the body instead of having to send an email to each individual for each topic.
The following is the code I currently use in my email generator.
Any help would be much appreciated.
Thanks,
I currently have a workbook that I use to send out overdue training assignments. I have a daily training report emailed to me. The overdue training assignments are in column A with the person's last name in B, first name in C, and their email address is in column D. I currently copy and paste columns B-D into my "email generator" that basically removes all the duplicate email addresses and then sends a generic " you have overdue training email"
What I would like it to do is send a single email to each individual with a list of the overdue training subjects in the body instead of having to send an email to each individual for each topic.
The following is the code I currently use in my email generator.
VBA Code:
Sub ComplyEmail()
Dim edress As String, Subject As String, name As String
Dim outlookapp As Object, outlookmailitem As Object
Dim X As Integer, erow As Integer
Dim emailBase As String
emailBase = "@wnco.com"
Range("A1:C1000").RemoveDuplicates Columns:=1, Header:=xlYes
erow = Sheet1.Cells(Sheet1.Rows.Count, "C").End(xlUp).Row
For X = 2 To erow
If Sheet1.Cells(X, 3).Value <> "" Then
Sheet1.Cells(X, 4).Value = Sheet1.Cells(X, 3).Value & emailBase
Else
Sheet1.Cells(X, 4).Value = ""
End If
Next X
Set outlookapp = CreateObject("Outlook.Application")
For X = 2 To erow
edress = Sheet1.Cells(X, 4)
name = Sheet1.Cells(X, 5)
If edress <> "" And name <> "" Then
Set outlookmailitem = outlookapp.CreateItem(0)
Subject = "Attention - You have overdue Training"
outlookmailitem.Body = "Good Morning " & name & "," & vbCrLf & vbCrLf & _
"Removed for security reasons"
outlookmailitem.To = edress
outlookmailitem.Subject = Subject
outlookmailitem.Display
End If
Next X
Set outlookapp = Nothing
End Sub
Any help would be much appreciated.
Thanks,