Hello,
I found this code on a blogspot belonging to Milos Holovsky.
Macros in Excel | What is an Excel Macro?: VBA to send a Outlook Draft Email to a list of emails in Excel
I am a complete beginner and I need your help.
This macro will loop through a list of emails addresses and send a template.
I manage to fiddle a bit with it to do what I want it to do.
Now the last thing I need from it is to customize the email title with a name which 2 cells before on the same line.
How can I do that?
Pls help!
Thanks,
JA
Here is teh code:
Sub TestEmail()
Dim OutMail As Object
Dim MyItem As Object
Sheets("Clients").Activate
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" Then
Set OutMail = CreateObject("Outlook.Application")
Set MyItem = OutMail.CreateItemFromTemplate("C:\Users\Milos\AppData\Roaming\Microsoft\Templates\Newsletter.oft")
With MyItem
.To = cell.Value
.Subject = "Newsletter"
.Display
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%s"
End With
On Error GoTo 0
Set OutMail = Nothing
Set MyItem = Nothing
End If
Next cell
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Set MyItem = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
I found this code on a blogspot belonging to Milos Holovsky.
Macros in Excel | What is an Excel Macro?: VBA to send a Outlook Draft Email to a list of emails in Excel
I am a complete beginner and I need your help.
This macro will loop through a list of emails addresses and send a template.
I manage to fiddle a bit with it to do what I want it to do.
Now the last thing I need from it is to customize the email title with a name which 2 cells before on the same line.
How can I do that?
Pls help!
Thanks,
JA
Here is teh code:
Sub TestEmail()
Dim OutMail As Object
Dim MyItem As Object
Sheets("Clients").Activate
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" Then
Set OutMail = CreateObject("Outlook.Application")
Set MyItem = OutMail.CreateItemFromTemplate("C:\Users\Milos\AppData\Roaming\Microsoft\Templates\Newsletter.oft")
With MyItem
.To = cell.Value
.Subject = "Newsletter"
.Display
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%s"
End With
On Error GoTo 0
Set OutMail = Nothing
Set MyItem = Nothing
End If
Next cell
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Set MyItem = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub