473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Syntax for System.Net.Mail send mail

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 <formand
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>";

*** Sent via Developersdex http://www.developersdex.com ***
Mar 1 '07 #1
1 1994
Mike P wrote:
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 <formand
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>";

*** Sent via Developersdex http://www.developersdex.com ***
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.

--
Göran Andersson
_____
http://www.guffa.com
Mar 1 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: paul brown | last post by:
Hi, I have this website that contains an internal message system that allows users to send each other "email" messages. My client wants me to extend the system so that when a user receives an...
4
by: Trond A. S. Andersen | last post by:
Hi, all! I'm trying to use the System.Web.Mail. "package" combinded with System.Web.Mail.SmtpMail in order to send MS Excel spreadsheets attached to mail messages. However, sending one single...
3
by: Phil Mc | last post by:
Hi has anyone come accross the problem.... with referance to System.Web.Mail.MailMessage and System.Web.Mail.SmtpMail THIS WORKS FINE mail=new MailMessage(); mail.From =...
5
by: martin | last post by:
Hi, I have created a class that is totally seperate from my web application. However this class is used extensivly by the web application for stuff like data access. I wish to add a function to...
3
by: pmud | last post by:
Hi, I have ab ASP.Net Application in which I need to send e-mail on button click. Even though my C# code for that is correct.I am getting the following error:: I think the following error can be...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
2
by: Ryan | last post by:
Hi, I receive an access denied error (see below) when attempting to send an email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same code works fine in a console...
0
by: howardr101 | last post by:
Hi, Have hunted around on the groups and can't find anything, hence. I've tried this against 2 mail servers (mailtraq and hmailserver) and it occus with both. The problems seems to be that...
2
by: clevrmnkey | last post by:
I've had nothing but trouble from the System.Net.Mail objects, but I finally need to make them work, and I can't for the life of me see what I'm doing wrong. I pared back my mail transaction to...
2
by: satnamsarai | last post by:
Using System.Net.Mail: Sometimes I get error 'failure sending mail. Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.' Not sure how...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.