Results 1 to 4 of 4
  1. #1
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Setting BodyFormat destroys all content (2003)

    I have a little event hook that fires up every time I reply to or forward an open message. By default I convert the HTML format replies and forwards to plain text. My old Outlook 2000 era code did this:

    <code>SendKeys "%ot", True 'the ultimate kludge!</code>

    Now that I have 2003, I thought I would try this:

    <code>miTarget.BodyFormat = olFormatPlain</code>

    Problem was, it seemed to blank out the message body completely (well, one space was left). If I used the de###### and single stepped very, very slowly, the body stayed there, but only sometimes. Googling did not uncover any helpful reports.

    I decided to work around this by saving the .Body to a string, making the format change, and then re-filling the .Body. This did odd things to the separator line, so I create my own. The code now is as follows, which is not pretty, but compared with SendKeys, which always prompted that annoying "Are you sure you want to" dialog, it's a big improvement:

    <code>Dim strMyBody As String
    strMyBody = Mid(miTarget.Body, InStr(1, miTarget.Body, "From:", vbTextCompare))
    miTarget.BodyFormat = olFormatPlain
    miTarget.Body = vbCrLf & vbCrLf & "-----Original Message-----" & vbCrLf & strMyBody</code>

    So here's the question: I assume this rigamarole really should not be necessary. Anyone know why I might be having this problem? Please don't do research unless you're truly curious, since the above seems to be working fine, but if you have run across this (or do in the future), perhaps we can collect experiences here and figure out what's going on.

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

    Re: Setting BodyFormat destroys all content (2003)

    A quick comment - when the code in my infamous Attachment Manager pasts a URL link to an HTML message body, it doesn't always show it right away, it only appears if I close and reopen the message. Does closing and reopening cause the HTML text to reappear in your application of myTarget.BodyFormat = olFormatPlain?
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Setting BodyFormat destroys all content (2003)

    > Does closing and reopening cause the HTML text to reappear...

    Ohhh, I don't think I can do that in this case. Or maybe I could if I save it as a Draft and magically re-open it again without losing the event. (It's a new reply/forward being composed, and there are a lot of things happening after the format change which might "die" if the message object suddenly disappears.)

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

    Re: Setting BodyFormat destroys all content (2003)

    I meant only that if you test your entire code on an HTML message which appears to lose all its body content, if the message is closed and then you return to it, does the content reappear? I'm asking because on my Attachment Manager and on some other code I run, there seems to be a delay in the HTML rendering operation, and what appears to be lost may need to be re-rendered/drawn. Or this could have nothing to do with your problem! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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