I'm getting a Type mismatch at ".Attachments.Add MyPath & Pic". Can someone see what I am doing wrong?
Sub Email()
' Set Tabs
Dim WSX As Worksheet
Set WSX = Worksheets("Email")
Dim objNotif_Email
Dim dist_list
Dim email_from As String
Dim email_subject
Dim email_body1, email_body2
Dim filepath As String
Dim new_report
Dim Pic As String, MyPath As String
'Setting fields
email_from = WSX.Cells(1, "B")
dist_list = WSX.Cells(2, "B")
email_subject = WSX.Cells(3, "B")
email_body1 = WSX.Cells(5, "B").Value & "<p><p>" & _
"<font FACE=Calibri SIZE=3 style=""color:red""><b>" & WSX.Range("B6:B6") & "</font></b><p>" & _
WSX.Range("B7:B7") & "<p>" & _
WSX.Range("B8:B8") & "<p>" & _
WSX.Range("B9:B9") & "<p>" & _
WSX.Range("B10:B10") & "<p>"
email_body2 = WSX.Range("B17:B17") & "<p>" & _
WSX.Range("B18:B18") & "<p>" & _
"<font FACE=Calibri SIZE=3 style=""color:Blue""><b>" & WSX.Range("B19:B19") & "</font></b><p>" & _
WSX.Range("B20:B20") & "<p>" & _
"<font FACE=Calibri SIZE=3 style=""color:Blue""><b>" & WSX.Range("B21:B21") & "</font></b><p>" & _
WSX.Range("B22:B22") & "<p>" & _
"<font FACE=Calibri SIZE=3 style=""color:Blue""><b>" & WSX.Range("B23:B23") & "</font></b><p>" & _
WSX.Range("B24:B24") & "<p>" & _
"<font FACE=Calibri SIZE=3 style=""color:Blue""><b>" & WSX.Range("B25:B25") & "</font></b><p><p>" & _
WSX.Cells(27, "B").Value & "<p>" & WSX.Cells(28, "B").Value
MyPath = "I:\PERISHABLES\Merchandising\National Merchandising\Slotting\Template\"
Pic = "Complete.png"
' Doing email
Set objNotif_Email = CreateObject("CDO.Message")
With objNotif_Email
.From = email_from
.BCC = dist_list
.Subject = email_subject
.Attachments.Add MyPath & Pic
.HTMLBody = email_body1 & "<img src='cid:Complete.png'" & "height=520 width=750>" & email_body2
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp-relay.cswg.com"
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "MerchandisingTeam"
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "123"
.Configuration.Fields.Update
'==End remote SMTP server configuration section==
' objNotif_Email.Display Does not suppot
.send
End With
End Sub
Sub Email()
' Set Tabs
Dim WSX As Worksheet
Set WSX = Worksheets("Email")
Dim objNotif_Email
Dim dist_list
Dim email_from As String
Dim email_subject
Dim email_body1, email_body2
Dim filepath As String
Dim new_report
Dim Pic As String, MyPath As String
'Setting fields
email_from = WSX.Cells(1, "B")
dist_list = WSX.Cells(2, "B")
email_subject = WSX.Cells(3, "B")
email_body1 = WSX.Cells(5, "B").Value & "<p><p>" & _
"<font FACE=Calibri SIZE=3 style=""color:red""><b>" & WSX.Range("B6:B6") & "</font></b><p>" & _
WSX.Range("B7:B7") & "<p>" & _
WSX.Range("B8:B8") & "<p>" & _
WSX.Range("B9:B9") & "<p>" & _
WSX.Range("B10:B10") & "<p>"
email_body2 = WSX.Range("B17:B17") & "<p>" & _
WSX.Range("B18:B18") & "<p>" & _
"<font FACE=Calibri SIZE=3 style=""color:Blue""><b>" & WSX.Range("B19:B19") & "</font></b><p>" & _
WSX.Range("B20:B20") & "<p>" & _
"<font FACE=Calibri SIZE=3 style=""color:Blue""><b>" & WSX.Range("B21:B21") & "</font></b><p>" & _
WSX.Range("B22:B22") & "<p>" & _
"<font FACE=Calibri SIZE=3 style=""color:Blue""><b>" & WSX.Range("B23:B23") & "</font></b><p>" & _
WSX.Range("B24:B24") & "<p>" & _
"<font FACE=Calibri SIZE=3 style=""color:Blue""><b>" & WSX.Range("B25:B25") & "</font></b><p><p>" & _
WSX.Cells(27, "B").Value & "<p>" & WSX.Cells(28, "B").Value
MyPath = "I:\PERISHABLES\Merchandising\National Merchandising\Slotting\Template\"
Pic = "Complete.png"
' Doing email
Set objNotif_Email = CreateObject("CDO.Message")
With objNotif_Email
.From = email_from
.BCC = dist_list
.Subject = email_subject
.Attachments.Add MyPath & Pic
.HTMLBody = email_body1 & "<img src='cid:Complete.png'" & "height=520 width=750>" & email_body2
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp-relay.cswg.com"
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "MerchandisingTeam"
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "123"
.Configuration.Fields.Update
'==End remote SMTP server configuration section==
' objNotif_Email.Display Does not suppot
.send
End With
End Sub