I have a spreadsheet with client names, email addresses, and appointment info. I export a .csv file from outlook. I have been doing a mail merge in word and then coping and pasting into an Outlook message and sending it out. I did some reseach and found code that I have made changes to. Of course they it doesn't work. I can't get anything to happen when I run this code. As always what am I doing worng?
Code:
Sub Qualls_Email_Confirms()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "C").Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Your Appointment with Marcus Qualls " & Cells(cell.Row, "W").Value
.Body = strbody
.Body = "Dear " & Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"Just a note to confirm our appointment" & vbNewLine & _
"Date: " & Cells(cell.Row, "H").Value & vbNewLine & _
"Time: " & Cells(cell.Row, "I").Value & vbNewLine & _
"Place: " & Cells(cell.Row, "W").Value & vbNewLine & vbNewLine & _
"Please reply back to this email to confirm you will be able to keep this appointment."
'You can add files also like this
'.Attachments.Add ("C:\test.txt")
.Display 'Or use Send
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub