Formatting a HtmlBody email string to include variables

Discussion in 'ASP General' started by Tom Petersen, Oct 13, 2005.

  1. Tom Petersen

    Tom Petersen Guest

    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!
    Tom Petersen, Oct 13, 2005
    #1
    1. Advertising

  2. Tom Petersen

    Paxton Guest

    Tom Petersen wrote:
    > 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
    Paxton, Oct 13, 2005
    #2
    1. Advertising

  3. Tom Petersen

    Tom Petersen Guest

    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...


    "Paxton" <> wrote in message
    news:...
    >
    > Tom Petersen wrote:
    >> 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
    >
    Tom Petersen, Oct 13, 2005
    #3
  4. Tom Petersen

    Phill. W Guest

    "Tom Petersen" <> wrote in message
    news:eo6omb$...
    > 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.
    Phill. W, Oct 13, 2005
    #4
  5. Tom Petersen

    Paxton Guest

    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

    Tom Petersen wrote:
    > 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...
    >
    >
    > "Paxton" <> wrote in message
    > news:...
    > >
    > > Tom Petersen wrote:
    > >> 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
    > >
    Paxton, Oct 13, 2005
    #5
  6. Tom Petersen

    Tom Petersen Guest

    just call me Homer Simpson! I knew that! Thanks for all of the help!!!

    "Paxton" <> wrote in message
    news:...
    > 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
    >
    > Tom Petersen wrote:
    >> 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...
    >>
    >>
    >> "Paxton" <> wrote in message
    >> news:...
    >> >
    >> > Tom Petersen wrote:
    >> >> 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
    >> >

    >
    Tom Petersen, Oct 13, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Danny Anderson
    Replies:
    5
    Views:
    483
    Victor Bazarov
    Aug 15, 2003
  2. Andreas Bogenberger
    Replies:
    3
    Views:
    885
    Andreas Bogenberger
    Feb 22, 2008
  3. Jabba Laci
    Replies:
    4
    Views:
    509
    Ethan Furman
    Jun 6, 2011
  4. mark4asp
    Replies:
    1
    Views:
    205
  5. Serge Myrand

    HTMLBody and variable

    Serge Myrand, Aug 9, 2004, in forum: ASP General
    Replies:
    6
    Views:
    186
    Patrice
    Aug 10, 2004
Loading...

Share This Page