Results 1 to 4 of 4
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097

    Using CDO to email HTML content in the body of the email

    I found a few places online that reference CDO as the only method that provides the means to embed graphic content within the body of an email. However, I've not found exactly how to do that. Does one create an HTML file and then some how use the CDO.Message object to load the body?



    Now that I've post'd, I found this: https://answers.microsoft.com/en-us/...a-9c18d8f94a95

    The link will ultimately lead one to the use of a procedure to read files into a variable that can subsequently be assigned to the text property of the CDO object. The only issue I see there is that the file types are txt, csv and SQL, but no reference to HTML files. I remain puzzled.

    Here's what I missed, there's another CDO property: .HTMLBody that one assigns the HTML string using the procedure referenced within the link above.

    I shall experiment............... Any additional suggestions would be most welcomed!

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I don't think you need CDO to embed an image in an html body. CDO is useful because you can bypass the email app and work with the email server directly. The only reason I ever used it was to get around the security prompt we used to get at that time. It also allowed me to send mail without using my own email account.

    I believe the tag you need is like "<img src=cid:ImageFileNameHere></img>"
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    So, you're saying that one simply inserts like "<img src=cid:ImageFileNameHere></img>" directly into a String variable and sends that string as the body property? (With the file image name of course)

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I don't think I've ever embedded an image with vba. I simply found that as a solution elsewhere, so you'll have to try it out. Before you decide it works (assuming it does) make sure you send a test email to someone who does not have access to that image file. If they can't see it but you can, then the image wasn't embedded. I would have thought the path to the file folder would be required, so that part looks suspicious. Don't forget - the email body has to be html format.
    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: 1
    Last Post: 06-19-2018, 10:38 AM
  2. email body using html format
    By baronqueefington in forum Programming
    Replies: 5
    Last Post: 02-03-2015, 03:44 PM
  3. Send email using CDO, get email addresses from table
    By marvinac1 in forum Programming
    Replies: 3
    Last Post: 12-22-2014, 12:54 PM
  4. Sending Reports with email body having HTML
    By CeVaEs_64 in forum Access
    Replies: 28
    Last Post: 11-26-2014, 12:13 PM
  5. Export html to body of email issue
    By mmart33 in forum Reports
    Replies: 3
    Last Post: 02-28-2013, 03:16 PM

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