Need help with 2 HTML files in the body of an email using excel co

T

Trefor

I did post this on the Excel forum, but did not get a reply, so thought I
might be able to get some help here?

I have tried to modify some code from Ron de Bruin site, but its not working.
I just get my signature and not the main body which comes from a file
"BodyFile". Any ideas?

SigString =
Workbooks(WorkbookMain).Sheets(DCSheet(Data%)).Range("Data_SignaturePath").Value

If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If

With OutMail
.To = ETo
.CC = Ecc
.BCC = EBcc
.Subject = ESubject
.HTMLBody = GetBoiler(AppPath & "\" & BodyFile) & "<br><br>" &
Signature
If EAttach <> "" Then .Attachments.Add EAttach
.Display
End With
 
S

Sue Mosher [MVP-Outlook]

We have no way of knowing what GetBoiler does, but your code below does nothing with Signature after it sets the value of that variable. Apparently you need to concatenate it with the information from BodyFIle.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
T

Trefor

Sue,

Thankyou for the reply.

"does nothing with Signature" Please note the variable at the end of the
line:
..HTMLBody = GetBoiler(AppPath & "\" & BodyFile) & "<br><br>" & Signature


Appoligies the GetBoiler is a routine from Dick Kusleika:

Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
 
S

Sue Mosher [MVP-Outlook]

Ah, I see. (Apparently I need that 2nd cup of coffee.) So what do those files look like? Remember you can't just slap two HTML files together. A valid HTML body can have only one set of <html> and <body> tags.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Trefor said:
Sue,

Thankyou for the reply.

"does nothing with Signature" Please note the variable at the end of the
line:
.HTMLBody = GetBoiler(AppPath & "\" & BodyFile) & "<br><br>" & Signature


Appoligies the GetBoiler is a routine from Dick Kusleika:

Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
 
T

Trefor

Sue,

The Signature file reads in my actual Outlook Signature file created in
Outlook. The "BodyFile" is simply a file that I created using Word and then
saved it as an HTML file. If this was the wrong this to do, how should I
create the Body file and/or can I edit these files to make them work?
 
T

Trefor

Sue,

OK perhaps I should state I know nothing about HTML, so

"Remember you can't just slap two HTML files together." Actually I had no
idea that you could not do this.

"A valid HTML body can have only one set of <html> and <body> tags.". On my
steep learning curve I have managed to open the HTML source of both files.
Your statement now makes a little more sense. Both files to have these tags,
can I just remove them from my bodyfile?

Another stupid question, sorry, does it matter how I saved this file from
word, I used Save As "Web Page (*.htm; *.html)"


--
Trefor


Trefor said:
Sue,

The Signature file reads in my actual Outlook Signature file created in
Outlook. The "BodyFile" is simply a file that I created using Word and then
saved it as an HTML file. If this was the wrong this to do, how should I
create the Body file and/or can I edit these files to make them work?
 
S

Sue Mosher [MVP-Outlook]

It all matters. This isn't really the place for an HTML 101 tutorial, I'm afraid, but you're on the right track.
Both files to have these tags,
can I just remove them from my bodyfile?

Think about it. You have looked at the source for two valid HTML files now. What do they have in common? If you take out some tags from the one file and then concantenate it with the other, will you still have a valid HTML file with the same structure as the files you have now? If necessary, use Notepad to make some small HTML files that are more readable than what Word puts out.

Your goal is to figure out what part of one file you need to put together with what part of the other file in order to have valid HTML. Once you understand that, a few snips with Replace() should do the trick.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top