Results 1 to 6 of 6
  1. #1
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544

    CDO email (gmail) make an image clickable

    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

  2. #2
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You appear to have an unmatched/lone single quote here 'C:\Clients.
    Rather than double quote everything in double quotes, I'd use "<font face='arial' size='3' color='black'> because it would help me spot this sort of thing more easily (if this were the complete line, I'd be missing the ending double quote before the red b). You might have other instances of this - I did not scour the code.
    Last edited by Micron; 08-09-2016 at 09:44 AM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Quote Originally Posted by Micron View Post
    You appear to have an unmatched/lone single quote here 'C:\Clients.
    Rather than double quote everything in double quotes, I'd use "<font face='arial' size='3' color='black'> because it would help me spot this sort of thing more easily (if this were the complete line, I'd be missing the ending double quote before the red b). You might have other instances of this - I did not scour the code.
    Thanks Micron I removed the single quote ('C:\Clients.) but get the same results. There aren't any others (single quotes). Thanks again.

  4. #4
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I didn't suggest you remove it. You need it, or using your method, nested double quotes because the path itself has to be in quotes. As for the image path, using single quotes you'd need
    Code:
    <img src='C:\Clients\customer\paymentbuttonhyperlink.png'
    with the necessary quotes around that for the rest of the variable construct.

    The rest of the html coming after that seems to be missing from your post, since I don't see an ending image tag either.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    I got it figured out. In case anyone else ever has the need, here is what worked for me:
    Code:
    msg.HTMLBody = msg.HTMLBody & "<a href='http://www.companyname.com/#pay-online'><img src='C:\Clients\companyname\paymentbuttonhyperlink.png' /></a>"

  6. #6
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    If you have others test it I'm certain you'll find they cannot see the image - unless they happen to have that file on their c drive in that location. Your first post indicated to me that you have recipients who are not part of your network. This assumes there isn't something about the code you're not showing which takes care the issue.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-19-2016, 07:46 AM
  2. send email with attachment using Gmail (CDO)
    By DubCap01 in forum Programming
    Replies: 2
    Last Post: 05-20-2016, 03:12 AM
  3. Replies: 5
    Last Post: 11-26-2013, 11:21 AM
  4. sending gmail email through access
    By TheShabz in forum Programming
    Replies: 20
    Last Post: 02-19-2012, 12:24 PM
  5. Email clickable button
    By Danzig in forum Access
    Replies: 21
    Last Post: 10-30-2010, 05:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums