I found some code on the internet which e-mails some stuff based on what you have in cells.
It works really well and attaches a file based on the file path and name being in a cell.
One thing I want to change is that if the file is not found, don't send the e-mai and give me an error message. Better yet, ask me if I still want to send the e-mail.
Right now if I type the file path and name, but i type something wrong, it sends the e-mail but with no attachement.
Here's the code.
Thanks
Dim OutApp As Object
Dim OutMail As Object
Dim ws As Worksheet
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set OutApp = CreateObject("Outlook.Application")
For Each ws In ActiveWorkbook.Worksheets
If ws.Range("B9").Value Like "?*@?*.?*" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = ws.Range("B9").Value
.CC = ws.Range("C9").Value
.BCC = ""
.Subject = ws.Range("D9").Value
.HTMLBody = RangetoHTML(Sheets("Body").Range("A5:A19"))
'You can add a file like this
.Attachments.Add ws.Range("F9").Value
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next ws
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Bookmarks