Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    May 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Send html-table from vba (Word/Excel 2000)

    I've used this code with success:

    Set OutApp = CreateObject("outlook.application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    With OutMail
    .To = "someone@domain.com"
    .CC = ""
    .BCC = ""
    .Subject = "Subject line"
    .Body = "Here goes the body"
    .Send 'or use .Display
    End With

    This code uses the default mail-format in outlook when creating the message.
    What I want is to use HTML and genereate a table in the body-field. The important point is the table. I can tell the users to set html as default, but if there is a nice way to change mailformat from VBA as well I would love to know.

    So, how can insert html-tags in the mail-body from my vba-code?

    I'll be thankful for all suggestions!
    -Roy

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

    Re: Send html-table from vba (Word/Excel 2000)

    The MailItem object has a property BodyFormat, you can set it to olFormatHTML. You can then set the HTMLBody property to a string with HTML tags.

    With OutMail
    .BodyFormat = olFormatHTML
    .To = "someone@domain.com"
    .Subject = "Subject line"
    .HTMLBody = "<HTML><H2>Hello there.</H2><BODY>This is an HTML message.</BODY></HTML>"
    .Send 'or use .Display
    End With

  3. #3
    New Lounger
    Join Date
    May 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Send html-table from vba (Word/Excel 2000)

    Thanks!!
    This seems to be just what I was looking for.

    Roy

Posting Permissions

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