Results 1 to 3 of 3
  1. #1
    cutterbl
    Guest

    HTML Editor (2000)

    I would use Exchange for this, but my client won't buy it...

    So, MSKB article Q183209 states:
    "If you are using an HTML Mail message, you can use the Outlook object model to access the HTML Document Object Model and use that object model to manipulate the embedded HTML."
    Sounds great. Well...first thing I found I had to do was create an object reference (they left that little tidbit out), but now I still haven't figured out the how. All I want to do is set the value of a variable using the contents of a div tag of an incoming mail message with a specific Subject. Nada...I've tried 27 different permutations to try and figure this out. Oh yeah, by the way, I tried the example code attached to the HTMLEditor help and, you guessed it, NADA. I'm going crazy. Here's my latest (of many) effort...

    Dim sSubject As String
    Dim sBody As String

    Set myInspector = Item.GetInspector
    Set myIExplorer = myInspector.HTMLEditor
    Set myContent = myIExplorer.All.Item
    sSubject = myContent.HTMLDivElement.ID("Subject").outerHTML
    sBody = myContent.HTMLDivElement.ID("body").outerHTML

    Set oldItem = Item
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNamespace("MAPI")
    Set myOlTaskFolder = myNameSpace.GetDefaultFolder(olFolderTasks)
    Set myItems = myOlTaskFolder.Items
    Set newDMVTaskItem = myItems.Add

    newDMVTaskItem.Subject = sSubject
    newDMVTaskItem.Body = sBody

    newDMVTaskItem.Save
    newDMVTaskItem.UnRead = True
    oldItem.UnRead = False
    oldItem.Delete

    Any help is greatly appreciated.

    Cutter

  2. #2
    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: HTML Editor (2000)

    I don't seem to have any online help for most of those properties and methods, and I don't have any messages handy that use DIV tags, so testing is difficult. I tried the code example from help for HTMLEditor and had to comment out the 'If' and 'End If' lines to get anything to happen.

    It would help if you write out, step by step, what you want the code to do. Then it should be easier to provide suggestions. Some of the initial code depends on the context. For example, do you want to work with the currently active open message, or a message selected in a folder, or all open messages, or all selected messages?

    Then, is the Subject likely to simply be the subject of the message (myItem.Subject) or is it really in a DIV tag in the message body? It seems that you are copying a Subject and Body from a mail message to a task item, and unless there is something that you absolutely need to dig out of the code, there should be much simpler ways to do this.

  3. #3
    cutterbl
    Guest

    Re: HTML Editor (2000)

    The concept is:
    1. upon receipt, if the subject line says "x" then it creates a new task item. (this works)
    2. Want to parse the HTML body to read the first div and set its contents as the subject of the new task item.
    3. Save the new task item and mark it unread.
    4. Mark the mail item as read and then delete it.

    This is all just part of the first phase. My company wants a web page where sales people enter in desired task information, results are emailed to a central location where tasks are created, then assigned. There will be several different types of tasks, hence the need for the subject of the mail message as a "catch". Content within the HTML message will be parsed to fill various fields in custom forms (tasks, calendar, etc.)

    I would use exchange for all of this, but my company is a little too cheap for that.

    After much experimenting I've come to this. Initially it will give me an error, which I choose to "Debug". I then "Continue" and it creates my new task, with the subject set to the contents of the div "bodyone" from the original MailItem.HTMLBody. Does Anyone know why I might receive the error (when it does work) and how I could maybe bypass it?

    If Item.Subject = "X TASK" Then
    Dim sSubject As String
    Dim sBody As String

    Set myInspector = Item.GetInspector
    Set myIExplorer = myInspector.HTMLEditor
    sSubject = myIExplorer.all("bodyone").innerText

    Set oldItem = Item
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNamespace("MAPI")
    Set myOlTaskFolder = myNameSpace.GetDefaultFolder(olFolderTasks)
    Set myItems = myOlTaskFolder.Items
    Set newDMVTaskItem = myItems.Add

    sBody = oldItem.Body

    newXTaskItem.Subject = sSubject
    newXTaskItem.Body = sBody

    newXTaskItem.Save
    newXTaskItem.UnRead = True
    oldItem.UnRead = False
    oldItem.Delete
    End If

    P.S. TypeName(myIExplorer.all("bodyone")) = HTMLDivElement, I had to add a reference to the Microsoft HTML Object Library in order to see it all, though you won't find any help topics you can at least see it in the object browser.

    Cutter

Posting Permissions

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