Hi All,
The below code is currently part of one of my subs, It’s toautomatically send an email when a button is pressed in the worksheet. Myquestion is how can I change this to make it send two separate emails withdifferent bodies and recipients?
Thanks in Advance
Tom
The below code is currently part of one of my subs, It’s toautomatically send an email when a button is pressed in the worksheet. Myquestion is how can I change this to make it send two separate emails withdifferent bodies and recipients?
Thanks in Advance
Tom
Code:
Dim wb1 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim OutApp As Object
Dim OutMail As Object
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set wb1 = ActiveWorkbook
TempFilePath = Environ$("temp") & "\"
TempFileName = "REJECTED Request -" & " " & Sheet2.Range("D9").Value
FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1)))
strto = Sheet2.Range("d39") & "@email.co.uk"
strcc = Sheet11.Range("X6")
strbcc = "[EMAIL="test@email.co.uk"]test@email.co.uk[/EMAIL]" & ";" & Sheet11.Range("L18")
strsubject = "HIGHLY SENSITIVE:(REJECTED) Request - " & Sheet2.Range("D9").Value & " - " & Sheet2.Range("G8").Value
strbody = "Your request has failed." & vbCrLf & "Please see below for further details:"
wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = strto
.CC = strcc
.BCC = strbcc
.Subject = strsubject
.Body = strbody
.Attachments.Add TempFilePath & TempFileName & FileExtStr
.send
End With
On Error GoTo 0
Kill TempFilePath & TempFileName & FileExtStr
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With