Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    874
    Thanks
    0
    Thanked 2 Times in 1 Post

    How To Use HTML Msg with CDO Lib. (Access 2000)

    I am using the CDO Library to send messages from an Access Database. These messages are going out in HTML format, but with only plan text being used in the message body, and it is working fine. Now I would like to learn how to include some of the capabilities of HTML messages in the body of these messages. For example, maybe be able to retrieve the contents of a Word Document saved in HTML format as the body of the outgoing message. With Outlook Express I can put all kinds of special formats in the body text of messages that are in HTML format. How can I get that same capability when I send the messages from this database instead of Outlook Express?

    As an alternative, does anyone know where I might be able to ask this question among users who are more familiar with using the CDO Library?

    Thanks,
    Bill

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How To Use HTML Msg with CDO Lib. (Access 2000)

    You can use the HTMLBody property of the CDO.Message object to set the body to a HTML string, or the CreateMHTMLBody method to set the body from a file or web page.

    See VBScript To Send Email Using CDO.

    If you search Google for CDO HTMLBody you'll find many other examples.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    874
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: How To Use HTML Msg with CDO Lib. (Access 2000)

    Thanks, Hans, for the very good reference and the suggestion to search for CDO HTMLBody. Both gave me some really good info. I had seen the HTMLBody key word before in other references but didn't understand how to use it and didn't think to search for that specifically. I'm still a little confused about HTMLBody versus CreateHTMLBody but I think the best thing for me to do now is to do some experimenting. The link you provided showed very specific code that I should be able to start with and probably use as-is. I've been tied up all day and haven't had a chance to try anything yet.

    Thanks,
    Bill

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How To Use HTML Msg with CDO Lib. (Access 2000)

    You can use HTMLBody to specify the body of the e-mail as a string containing HTML tags, for example:

    objMsg.HTMLBody = "Dear John [i]Jones</>"

    which would result in

    Dear John Jones

    The CreateHTMLBody method is used to load the body of the e-mail from a HTML file on disk (or from a web page), for example:

    objMsg.CreateHTMLBody "file://c:/myfolder/myfile.htm"

    This will take the HTML file myfile.htm and use its contents as the body of the e-mail.

  5. #5
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    874
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: How To Use HTML Msg with CDO Lib. (Access 2000)

    OK, that clears it up very well. I just tried creating a Word document with some special formatting and then saving it in .HTM format and then I used CreateMHTMLBody and it worked. I tried CreateHTMLBody first and it didn't work but I saw a mention of the special Microsoft version of CreateMHTMLBody in one of the references you referred me to. I suppose Word uses the special Microsoft version of HTML. I'm not aware of any program that I might already have that creates the general version of HTML and Word is convenient to use so I'm fine with that approach.

    One puzzle that I encountered several days ago is still puzzling. I was entering the message body in a TextBox in the Access form. I tried just typing in a URL and it remained just plain text in the resulting message. Then I entered a URL in Word or Outlook Express and it was converted to a hyperlink. Then I copied the hyperlink and pasted it into my TextBox and it came out a hyperlink in the message. Then I went through the same process with some Bold text and it did not come out Bold in the message. I was using TextBody in both cases. Any idea why the URL worked and the Bold didn't?

    Thanks for your help.
    Bill

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How To Use HTML Msg with CDO Lib. (Access 2000)

    Text boxes in Access contain plain text, they don't support formatting part of the text, so attributes such as bold, italic etc. will not be passed to the e-mail message.

    The e-mail engine scans the body of an e-mail for text that looks like an URL or e-mail address, and converts it to a clickable link.

  7. #7
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    874
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: How To Use HTML Msg with CDO Lib. (Access 2000)

    Yes, I expected the formatting to be dropped when I pasted into a text box. I was surprised to see the URL link retain its blue color and underline when I pasted it into the text box. Of course, it might not have actually been a link to the web site at that point but it looked like one. I can understand how the final message may have recognized it as a link and treated it as such.

    Thanks for adding to my education.

    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •