Syntax for System.Net.Mail send mail

M

Mike P

I am building a message body to be sent by email, but I can't seem to
get the correct syntax for 2 lines where I am defining the <form> and
trying to pass parameters and where I am creating a hyperlink and again
trying to pass parameters to it. I have tried escaping the "s both like
this : \" and by replacing them with single quotes : ', but neither
method seems to pass the parameters, when I hover over the link I just
get an empty first parameter i.e. ?remail= Can anybody advise?

Form line :

message.Body += "<FORM name='frmReferredEmail'
action='thank_you_referred.aspx?email=' + strEmailAddress + '&remail=' +
strEmailAddressRecommended + '&rpolicy=' + strPolicyNumber + '''
method='get'>";

Hyperlink line :

message.Body += "<tr><td><font color='black' face='Arial, Helvetica,
sans-serif' style='font-size: 11px'>If you have any problems submitting
this form please click <a class=mBlue
href='http://lbm-engine.com/insure/referred_web.aspx?remail=' +
strEmailAddressRecommended + '&email=' + strEmailAddress + '&rpolicy=' +
strPolicyNumber + '''>here</a>";
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Mike said:
I am building a message body to be sent by email, but I can't seem to
get the correct syntax for 2 lines where I am defining the <form> and
trying to pass parameters and where I am creating a hyperlink and again
trying to pass parameters to it. I have tried escaping the "s both like
this : \" and by replacing them with single quotes : ', but neither
method seems to pass the parameters, when I hover over the link I just
get an empty first parameter i.e. ?remail= Can anybody advise?

Form line :

message.Body += "<FORM name='frmReferredEmail'
action='thank_you_referred.aspx?email=' + strEmailAddress + '&remail=' +
strEmailAddressRecommended + '&rpolicy=' + strPolicyNumber + '''
method='get'>";

Hyperlink line :

message.Body += "<tr><td><font color='black' face='Arial, Helvetica,
sans-serif' style='font-size: 11px'>If you have any problems submitting
this form please click <a class=mBlue
href='http://lbm-engine.com/insure/referred_web.aspx?remail=' +
strEmailAddressRecommended + '&email=' + strEmailAddress + '&rpolicy=' +
strPolicyNumber + '''>here</a>";

You have used an apostrophe instead of a quotation mark where you try to
end the string. That means that you are ending the property in the html
code instead of the string, and the variables are not used at all to
make the string.


You should url encode the values that goes in the query string, then you
should html encode the entire property value:

string action = "thank_you_referred.aspx?email=" +
Server.UrlEncode(strEmailAddress) + "&remail=" +
Server.UrlEncode(strEmailAddressRecommended) + "&rpolicy=" +
Server.UrlEncode(strPolicyNumber)

message.Body += "<FORM name=\"frmReferredEmail\" action=\"" +
Server.HtmlEncode(action) + "\" method=\"get\">";

This will properly encode anything that you put in the strings.
 

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,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top