Syntax for System.Net.Mail send mail

Discussion in 'ASP .Net' started by Mike P, Mar 1, 2007.

  1. Mike P

    Mike P Guest

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



    *** Sent via Developersdex http://www.developersdex.com ***
    Mike P, Mar 1, 2007
    #1
    1. Advertising

  2. 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 <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>";
    >
    >
    >
    > *** 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
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Mar 1, 2007
    #2
    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. =?Utf-8?B?Unlhbg==?=
    Replies:
    2
    Views:
    3,879
    Steven Cheng[MSFT]
    Feb 28, 2006
  2. Brad
    Replies:
    2
    Views:
    9,667
  3. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    System.Net.Mail vs System.Web.Mail

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Jun 16, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    10,577
    Walter Wang [MSFT]
    Jun 16, 2006
  4. refv8
    Replies:
    2
    Views:
    27,035
    ittower
    Oct 13, 2006
  5. Nathan Sokalski
    Replies:
    5
    Views:
    898
    Spam Catcher
    Dec 12, 2006
Loading...

Share This Page