helios1014
New Member
- Joined
- Feb 18, 2018
- Messages
- 1
I am looking for a method of creating a set of emails fitting the following parameters:
-each email will be personalized to the recipient and based off a template letter set by my supervisor.
-There will be a greeting line with their name and title, along with the names of the departments they oversee.
-each email will have a set of documents specific to that recipient.
-they should be saved to file for final inspection before they are sent.
-column 5 that is not referenced in the code below is the column containing the department name.
The closest I have come is the following code:
Sub send_template_w/attachments()
On Error Resume Next
Dim o As Outlook.Application
Set o = New Outlook.Application
Dim omail As Outlook.Mailitem
Set omail =.Createitem(olMailitem)
Dim I As Long
For i=2 To Range(“a100”).End(xlUp).Row
With omail
.Body = “Dear “ & Cells(i,1).Value
.To = Cells(i,2).Value
.CC = Cells(i,3).Value
.Subject = Cells(i,4).Values
.Attachments.Add Cells(i,6)
.Attachments.Add Cells(i,7)
.SaveAs Environ("HOMEPATH") &; "\My Documents" & Cells(i,2).Value
End With
Next
End Sub
So far this code will generate and save an email but what I want to do is use a present email template for these emails--either by adding the greeting at the beginning and department name into the body of the the email to be sent out. Can this be done through a word or Outlook document and if so, how?
-each email will be personalized to the recipient and based off a template letter set by my supervisor.
-There will be a greeting line with their name and title, along with the names of the departments they oversee.
-each email will have a set of documents specific to that recipient.
-they should be saved to file for final inspection before they are sent.
-column 5 that is not referenced in the code below is the column containing the department name.
The closest I have come is the following code:
Sub send_template_w/attachments()
On Error Resume Next
Dim o As Outlook.Application
Set o = New Outlook.Application
Dim omail As Outlook.Mailitem
Set omail =.Createitem(olMailitem)
Dim I As Long
For i=2 To Range(“a100”).End(xlUp).Row
With omail
.Body = “Dear “ & Cells(i,1).Value
.To = Cells(i,2).Value
.CC = Cells(i,3).Value
.Subject = Cells(i,4).Values
.Attachments.Add Cells(i,6)
.Attachments.Add Cells(i,7)
.SaveAs Environ("HOMEPATH") &; "\My Documents" & Cells(i,2).Value
End With
Next
End Sub
So far this code will generate and save an email but what I want to do is use a present email template for these emails--either by adding the greeting at the beginning and department name into the body of the the email to be sent out. Can this be done through a word or Outlook document and if so, how?