As Carl pointed out, you're just smithing a string and setting the .Body
property.
If you have a lengthy body, you might benefit from using the
System.Text.StringBuilder class instead, doing a bunch of .Append () and
..AppendFormat () 's to create your body, and then set the email object's
..Body to the StringBuilder.ToString () result;
using System.Text;
StringBuilder sb = new StringBuilder ();
sb.Append ("Dear {0} {1},\n",
Request.QueryString("FirstName"),
Request.QueryString("LastName"));
sb.Append ("\n");
sb.Append ("How do you want your Spam sent to you today? ;-)");
objMailMessage.Body = sb.ToString ();
Make sure to do HtmlEncodes and to do your necessary HTML formatting if you
want the message body to be HTML.
An alternative is to use a product like AspNetEmail;
http://www.aspnetemail.com/
Out of the box, this gives you two alternatives to building your email body
in code;
1) built-in mail-merging through templates.
2) the ability to send a webpage as the email body content. This lets you
design and code your email body as a standard ASPX page, complete with
databound controls, calculations, etc. When you send the message,
AspNetEmail makes a request to your page and generates the email content on
the fly.
/// M
"Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message
news:eL**************@TK2MSFTNGP15.phx.gbl...
William Gower wrote: I am creating an email message to be sent from a web page. How do I
embed variables like strFirstName, strLastName etc. into the body
objMailMessage.Body = "Dear " & _
Server.HtmlEncode(Request.QueryString("FirstName") ) & " " & _
Server.HtmlEncode(Request.QueryString("LastName")) & ",\n" & _
"How do you want your Spam sent to you today? ;-)"
--
Thanks,
Carl Prothman
Microsoft ASP.NET MVP