Good morning!
I am trying to include an image in a CDO email that when clicked, will take the user to the website. Here is the full code (which works great except I don't know how to add the ref to the img src (underlined below). When I click it now, I receive the email without image and the word "TRUE". ??
Thanks in advance for sharing your knowledge.
Code:
Private Sub Email_Invoice_Click()
On Error GoTo errHandler
DoCmd.SetWarnings False
If IsNull(Forms![mainProcessEntry]![UserEmail]) Then
MsgBox "Please enter your email address"
DoCmd.OpenForm "mainprocessentry"
Forms![mainProcessEntry]![UserEmail].SetFocus
Exit Sub
End If
Dim strpath As String
Dim stDocName As String
Dim mypath As String
Dim objCDO As New CDO.Message
Dim objBP As CDO.IBodyPart
strpath = "C:\Invoices\"
mypath = strpath & "invoice.pdf"
Debug.Print mypath
Me.invoicepath = mypath
MyFileName = mypath
emailfile = CStr(mypath & ".pdf")
stDocName = "rptinvoice"
DoCmd.OutputTo acReport, stDocName, acFormatPDF, mypath, False
Dim msg As Object
Set msg = CreateObject("CDO.Message")
msg.From = Forms![mainProcessEntry]![UserEmail]
msg.to = [Forms]![mainProcessEntry]![invoiceemail1]
Debug.Print msg.to
msg.Subject = "Your Invoice is Attached"
msg.textbody = "Thank you!"
msg.CC = ""
msg.BCC = ""
msg.ReplyTo = strMailFrom
msg.AddAttachment "c:\invoices\invoice.pdf"
msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = Forms![mainProcessEntry]![UserEmail]
msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Forms![mainProcessEntry]![Password]
msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
msg.Configuration.Fields.Update
msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""3"" color=""black""><b>Company, LLC</b></font><BR>"
msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""blue"">"
msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""black"">418 Any Rd.</font><BR>"
msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""black"">Ellisville, MS 39437</font><BR>"
msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""black"">(601) 555-5555 office</font><BR>"
msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""black"">(877) 444-4444 fax</font><BR>"
msg.HTMLBody = msg.HTMLBody & "<font face=""arial"" size=""2"" color=""blue""><b><BR>http://www.company.com</b></font><BR>"
msg.HTMLBody = msg.HTMLBody & Forms![mainProcessEntry]![UserEmail]
msg.HTMLBody = msg.HTMLBody & "<font face=""Arial"" size=""2"" color=""green""><u>" & SW & "</u></font><BR>"
msg.HTMLBody = msg.HTMLBody & "<font face=""Arial"" size=""2"" color=""blue"">"
msg.HTMLBody = msg.HTMLBody & "<img src='C:\Clients\customer\paymentbuttonhyperlink.png <a href= http://www.customer.com/#pay-online " > ""
'msg.htmlbody = msg.htmlbody & "<img src=C:\Clients\customer\paymentbuttonhyperlink.png" title="Pay Online" width="300" height="200" /> msg'.HTMLBody = msg.HTMLBody & "<a href="http://www.website.com/#pay-online.html"><img src="C:\Clients\customer\paymentbuttonhyperlink.png" title="Pay Online" width="300" height="200" /></a>"
msg.Send
Exit Sub
errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"
End Sub