jrobertson83
02-23-2019, 09:24 PM
Hello,
I have pieced this code together from various sites that will go down the excel file and email all the email addresses I have populated.
My question is, the code just sends an email with whatever the body is in that column. Is there a way I can have those messages/body a saved .oft template?
Code i Have:
Set sh = ThisWorkbook.Sheets("Sheet1")
Dim OA As Object
Dim msg As Object
Set OA = CreateObject("Outlook.Application")
Dim i As Integer
Dim last_row As Integer
last_row = Application.WorksheetFunction.CountA(sh.Range("A:A"))
For i = 2 To last_row
Set msg = OA.Createitem(0)
msg.to = sh.Range("A" & i).Value
msg.cc = sh.Range("B" & i).Value
msg.Subject = sh.Range("C" & i).Value
msg.body = sh.Range("D" & i).Value
If sh.Range("E" & i).Value <> "" Then
msg.Attachments.Add sh.Range("E" & i).Value
End If
msg.Send
Next i
MsgBox "Update Request Sent"
End Sub
I have pieced this code together from various sites that will go down the excel file and email all the email addresses I have populated.
My question is, the code just sends an email with whatever the body is in that column. Is there a way I can have those messages/body a saved .oft template?
Code i Have:
Set sh = ThisWorkbook.Sheets("Sheet1")
Dim OA As Object
Dim msg As Object
Set OA = CreateObject("Outlook.Application")
Dim i As Integer
Dim last_row As Integer
last_row = Application.WorksheetFunction.CountA(sh.Range("A:A"))
For i = 2 To last_row
Set msg = OA.Createitem(0)
msg.to = sh.Range("A" & i).Value
msg.cc = sh.Range("B" & i).Value
msg.Subject = sh.Range("C" & i).Value
msg.body = sh.Range("D" & i).Value
If sh.Range("E" & i).Value <> "" Then
msg.Attachments.Add sh.Range("E" & i).Value
End If
msg.Send
Next i
MsgBox "Update Request Sent"
End Sub