Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Apr 2003
    Location
    Lakewood, Washington, USA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HTMLBody property of MailItem (Outlook 2000)

    I'm using Access2000 to automate Outlook. The Outlook message does not change to HTML when I set the HTMLBody property of the MailItem to True. Here's the basic code:

    Set objMailItem = objOutlook.CreateItem(0)

    objMailItem.HTMLBody=True

  2. #2
    5 Star Lounger
    Join Date
    May 2001
    Location
    Washington, USA
    Posts
    750
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HTMLBody property of MailItem (Outlook 2000)

    HTMLBody is not a true/false. It's where your tags, code and text would go. Using htmlBody instead of body is all you have to do.

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: HTMLBody property of MailItem (Outlook 2000)

    To convert, would I use something like this?

    objItem.HTMLBody = objItem.Body
    -John ... I float in liquid gardens
    UTC -7ąDS

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Washington, USA
    Posts
    750
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HTMLBody property of MailItem (Outlook 2000)

    Yes, that would do the trick I think.

  5. #5
    5 Star Lounger
    Join Date
    May 2001
    Location
    Washington, USA
    Posts
    750
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HTMLBody property of MailItem (Outlook 2000)

    To be safe, I should have qualified. I assumed you'd have the tags in place too. But my assumptions have a way of biting back.

  6. #6
    5 Star Lounger
    Join Date
    May 2001
    Location
    Washington, USA
    Posts
    750
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HTMLBody property of MailItem (Outlook 2000)

    In case you're still looking, below is a sample application that works with html body. It builds a summary of a day's appointments and summarizes them in an html table. It's driven from the Outlook side, but might provide some ideas...

    Sub MailTodaysAppts()
    Dim strAns As String
    Dim dteAns As Date
    Dim strDefaultDate

    strDefaultDate = Date + 1
    strAns = InputBox("Enter the date to report MM/DD/YY): ", "Date Input", strDefaultDate)

    If strAns <> "" Then ' Cancel was clicked so do nothing
    If IsDate(strAns) Then
    dteAns = strAns
    Else
    dteAns = Date ' Didn't enter a valid date so assume today
    End If
    End If

    Call MailAnyDaysAppts(dteAns)

    End Sub

    Sub MailAnyDaysAppts(dteDate As Date)
    Dim objApp As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim colCal As Outlook.Items
    Dim strFind As String
    Dim colMyAppts As Outlook.Items
    Dim objAppt As Outlook.AppointmentItem
    Dim objMsg As Outlook.MailItem
    Dim strHTML As String

    ' start HTML for message
    strHTML = "

    Here are my appointments for " & _
    FormatDateTime(dteDate, vbLongDate) & _
    ":</p><table>"

    Set objApp = CreateObject("Outlook.Application")
    Set objNS = Application.GetNamespace("MAPI")
    Set colCal = objNS.GetDefaultFolder(olFolderCalendar).Items
    colCal.Sort "[Start]"
    colCal.IncludeRecurrences = True

    ' get appointments spanning date
    strFind = "[Start] < " & _
    Quote(Format(dteDate, "dd mmm yyyy") & " 12:00 AM") & _
    " AND [End] > " & _
    Quote(Format(dteDate, "dd mmm yyyy") & " 12:00 AM")
    Debug.Print strFind
    Set colMyAppts = colCal.Restrict(strFind)
    For Each objAppt In colMyAppts
    strHTML = strHTML & AddApptRow(objAppt)
    Next
    Set colMyAppts = Nothing

    ' get appointments starting on date
    strFind = "[Start] >= " & _
    Quote(Format(dteDate, "dd mmm yyyy") & " 12:00 AM") & _
    " AND [Start] < " & _
    Quote(Format(dteDate + 1, "dd mmm yyyy") & " 12:00 AM")
    Debug.Print strFind
    Set colMyAppts = colCal.Restrict(strFind)
    For Each objAppt In colMyAppts
    strHTML = strHTML & AddApptRow(objAppt)
    Next

    ' create new message
    Set objMsg = objApp.CreateItem(olMailItem)
    With objMsg
    .Subject = "Appointments for " & _
    FormatDateTime(dteDate, vbLongDate)
    .HTMLBody = strHTML & "</table>"
    .Display
    End With

    Set objApp = Nothing
    Set objNS = Nothing
    Set colCal = Nothing
    Set colMyAppts = Nothing
    Set objAppt = Nothing
    End Sub

    Function AddApptRow(objAppt As Outlook.AppointmentItem) As String
    Dim strRow As String
    strRow = "<tr><td valign=" & Quote("top") & _
    "width=" & Quote("100") & ">"
    If objAppt.AllDayEvent = True Then
    strRow = strRow & "All day"
    Else
    strRow = strRow & _
    FormatDateTime(objAppt.Start, vbShortTime) & _
    " - " & FormatDateTime(objAppt.End, vbShortTime)
    End If
    strRow = strRow & "</td><td valign=" & Quote("top") & ">" & _
    objAppt.Subject
    If objAppt.Location <> "" Then
    strRow = strRow & " (" & _
    objAppt.Location & ")"
    End If
    strRow = strRow & "

    "
    If objAppt.Body <> "" Then
    strRow = strRow & objAppt.Body & "

    "
    End If
    strRow = strRow & "</td>"
    AddApptRow = strRow
    End Function

    Function Quote(MyText)
    Quote = Chr(34) & MyText & Chr(34)
    End Function

  7. #7
    New Lounger
    Join Date
    Apr 2003
    Location
    Lakewood, Washington, USA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HTMLBody property of MailItem (Outlook 2000)

    Thanks to everyone who responded. I resolved the problem by:

    .HTMLBody=""

    I did it this way because the email is opened by the program so the user can cut and past a word doc into the email message in HTML format.

    It now works.

Posting Permissions

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