From Excel VBA, I am creating an outlook email message. I want to have the
body contain an html file. Is there any way to load this html from a file,
instead of having to put into the VBA code?
From Excel VBA, I am creating an outlook email message. I want to have the
body contain an html file. Is there any way to load this html from a file,
instead of having to put into the VBA code?
Erin shared this with us in microsoft.public.excel.programming:
> From Excel VBA, I am creating an outlook email message. I want to
> have the body contain an html file. Is there any way to load this
> html from a file, instead of having to put into the VBA code?
You could put it in from a file to a string using the Textstreamobject.
Essentially, you read the html file, put its content in a string, and
use that string in your vba code.
Read the help on that subject, it actually contains a good example.
--
Amedee Van Gasse using XanaNews 1.17.3.1
If it has an "X" in the name, it must be Linux?
How To Ask Questions The Smart Way
http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively
http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
Only ask questions with yes/no answers if you want "yes" or "no" as the
answer.
http://homepages.tesco.net/~J.deBoyn...-with-yes-or-n
o-answers.html
Set objOutlook = New Outlook.Application
Set objEMailMsg = objOutlook.CreateItem(itemtype:=olMailItem)
'Show mail but don't actually send!
If sBody <> "" Then
With objEMailMsg
.Subject = "P&P Summary for " & REPORTDATE
.HTMLBody = NameValue(NAV_MESSAGE) & vbCrLf & sBody
.Display
End With
"Erin" wrote:
> From Excel VBA, I am creating an outlook email message. I want to have the
> body contain an html file. Is there any way to load this html from a file,
> instead of having to put into the VBA code?
I forgot to alter something.
NameValue(NAV_MESSAGE) & vbCrLf & sBody
is simple the path to the html file plus some additional text
eg
.HTMLBody = "C:\Demo.html" & vbCRLF & "Hello World!"
"Patrick Molloy" wrote:
>
> Set objOutlook = New Outlook.Application
> Set objEMailMsg = objOutlook.CreateItem(itemtype:=olMailItem)
>
> 'Show mail but don't actually send!
> If sBody <> "" Then
> With objEMailMsg
>
> .Subject = "P&P Summary for " & REPORTDATE
>
> .HTMLBody = NameValue(NAV_MESSAGE) & vbCrLf & sBody
>
> .Display
>
> End With
>
>
>
>
>
> "Erin" wrote:
>
> > From Excel VBA, I am creating an outlook email message. I want to have the
> > body contain an html file. Is there any way to load this html from a file,
> > instead of having to put into the VBA code?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks