Get HTML Email body into IE document object
Get HTML Email body into IE document object
(OP)
I have a need to open Outlook emails, which contain HTML tables. I need to parse some data out of the tables.
I have the email in an object, and can access the HTML body:
Set objOutlook = CreateObject("Outlook.Application")
Set objEmail = objOutlook.CreateItemFromTemplate(EmailFile)
MsgBox(objEmail.body)
MsgBox(objEmail.htmlbody
Unless I'm headed down the wrong path, I'd like to get that htmlbody into an IE.document so I can use some of the GetElement methods to retrieve the data I need.
Can someone point me in the right direction, or to some documentation?
Thanks
Fred
I have the email in an object, and can access the HTML body:
Set objOutlook = CreateObject("Outlook.Application")
Set objEmail = objOutlook.CreateItemFromTemplate(EmailFile)
MsgBox(objEmail.body)
MsgBox(objEmail.htmlbody
Unless I'm headed down the wrong path, I'd like to get that htmlbody into an IE.document so I can use some of the GetElement methods to retrieve the data I need.
Can someone point me in the right direction, or to some documentation?
Thanks
Fred
RE: Get HTML Email body into IE document object
CODE
Set HTMLDoc = CreateObject("HTMLFile") HTMLDoc.body.innerHTML = objEmail.htmlBody
You should then be able to parse HTMLDoc using getelement methods
RE: Get HTML Email body into IE document object
Fred
RE: Get HTML Email body into IE document object
CODE -->
I get the runtime error: Object required: 'HTMLDoc.body' 800A01A8
TEST2.html was just to prove that I was looking at the right data. I found several cases of the same error in forums on the web, but no solutions. Do I need to invoke MSHTML in some way?
Thanks.
RE: Get HTML Email body into IE document object
Try
HTMLDoc.Write objEmail.htmlBody
HTMLDOC.Close
Instead of
HTMLDoc.body.innerHTML = objEmail.htmlBody
RE: Get HTML Email body into IE document object
CODE -->
CODE -->
Thanks.
RE: Get HTML Email body into IE document object
CODE -->
Assume the above fragment in the html body of that email. I'm trying to extract the policy number "PMP0975891".
If I can extract the string "<b>Policy/Quote#:</b> PMP0975891" then I can deal with it.
I figured I'd get a list of elements with class 'text' and from that, find the one containing the value "Policy/Quote#:".
Is that reasonable? In any case, right out of the gate I'm having trouble getting the list of objects. Samples I've found online aren't helping me. I've tried stuff like:
CODE -->
Thanks in advance.
RE: Get HTML Email body into IE document object
RE: Get HTML Email body into IE document object
CODE -->