Guys,
Can someone check my code. I've made some changes but its not working.
Sub TestFile()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Sheets("2006").Columns("V").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And LCase(cell.Offset(0, 9).Value) = "Late" Then
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = cell.Value
.Subject = "Reminder"
.Body = "Dear " & cell.Offset(0, -19).Value & vbNewLine & vbNewLine & _
"Please contact us to discuss bringing your account up to date" & vbNewLine & vbNewLine & _
"Please refer to U-order number" & cell.Offset(0, -2).Value & vbNewLine & vbNewLine & _
"This an automated generated email, you don't need to reply"
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'Or use Display
End With
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Bookmarks