Formatting a HtmlBody email string to include variables

T

Tom Petersen

I have this:
1 emailBody = "<html>" & vbCrLf _
2 & "<head>" & vbCrLf _
3 & "<title>Interpreter Request details</title> " &
vbCrLf _
4 & "</head> " & vbCrLf _
5 & "<body> " & vbCrLf _
6 & "<font face=Verdana><b>Interpreter Request
details: " & vbCrLf _
7 & "Requestor: </b><u> <% strFName strLName %></u>"
& vbCrLf _
...
& "</body> " & vbCrLf _
& "</html> " & vbCrLf

In line 7, I need to display the results of the variables strFName and
strLName (and have a space in between the two) but I don't know the proper
formatting. If I just use the & then I get the literal strFname instead of
the value. Could someone please show me the correct syntax for this?

TIA!
 
P

Paxton

Tom said:
I have this:
1 emailBody = "<html>" & vbCrLf _
2 & "<head>" & vbCrLf _
3 & "<title>Interpreter Request details</title> " &
vbCrLf _
4 & "</head> " & vbCrLf _
5 & "<body> " & vbCrLf _
6 & "<font face=Verdana><b>Interpreter Request
details: " & vbCrLf _
7 & "Requestor: </b><u> <% strFName strLName %></u>"
& vbCrLf _
...
& "</body> " & vbCrLf _
& "</html> " & vbCrLf

In line 7, I need to display the results of the variables strFName and
strLName (and have a space in between the two) but I don't know the proper
formatting. If I just use the & then I get the literal strFname instead of
the value. Could someone please show me the correct syntax for this?

TIA!

Line 7: & "Requestor: </b><u>" & strFName & " " & strLName & "</u>"
& vbCrLf _

assuming you want a space between strFName and strLName

Paxton
 
T

Tom Petersen

That worked great, what a pain! Thanks!

One last thing, my vbCrLf doesn't seem to work, isn't that supposed to be a
carriage return? Everthing is on the same line and I need it to have an
'enter' after some of the lines...
 
P

Phill. W

Tom Petersen said:
I have this:
1 emailBody = "<html>" & vbCrLf _ .. . .
In line 7, I need to display the results of the variables strFName
and strLName (and have a space in between the two) but I don't
know the proper formatting.

Remember, all you're doing is building up a String that "just happens"
to have HTML in it.

emailBody = "<html>" & vbCrLf _
. . .
& "<body>" & vbCrLf _
& "<font face=Verdana>"
& <b>Interpreter Request details: " & "<br>" & vbCrLf _
& "Requestor: </b><u>" _
& strFName & " " & strLName _
& "</u>" & "<br>" & vbCrLf _
. . .
& "</body> " & vbCrLf _
& "</html> " & vbCrLf

Note the use of "<br>" & vbCrLf to force an HTML-style line
break - HTML does not care about white-space; only HTML tags.

HTH,
Phill W.
 
P

Paxton

VbCrLf is for line breaks in text emails. <br> does it in html.

So line 6 and 7 should look like this:

6 & "<font face=Verdana><b>Interpreter Request details: <br>" & _
7 & "Requestor: </b><u>" & strFName & " " & strLName & </u><br>" & _
etc....

Paxton
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top