Hello,
I am trying to use one button to send multiple emails to two different people. The messages and email addresses are in cells in the spread sheet, so I refer to them as ranges. When I click the button, the first email goes out perfectly, but the second one never sends. Can someone please help me? Here is what I have so far:
Private Sub FillOutNewHireForm_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim Body1 As Range
Dim Body2 As Range
Dim Hire As Range
Dim Email1 As Range
Dim Email2 As Range
Set Email1 = Worksheets("Tasks").Range("K5")
Set Email2 = Worksheets("Tasks").Range("L5")
Set Hire = Worksheets("Tasks").Range("C1")
Set Body1 = Worksheets("Tasks").Range("F5")
Set Body2 = Worksheets("Tasks").Range("G5")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Email1
.CC = ""
.BCC = ""
.Subject = "New-Hire task: Fill out New-Hire Form for " & Hire
.Body = Body1
.Attachments
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send
End With
On Error Resume Next
With OutMail
.To = Email2
.CC = ""
.BCC = ""
.Subject = "New-Hire task: Please share Personal Folder with " & Hire
.Body = Body2
.Attachments
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send
End With
On Error GoTo 0
MsgBox ("Email Sent")
Range("A5").Value = "Complete"
ThisWorkbook.Save
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Bookmarks