c# - Why am I getting "The specified string is not in the form required for an e-mail address" here? -


the relevant code is

    [httppost]     public actionresult getlinkbyname ( string pname )     {         partneridandemail pinfo = this._db.getpartnerbyname(pname);         if ( pinfo != null )         {             try             {                 var m = new system.net.mail.mailmessage()                 {                     subject = "your survey link",                     body = string.format("<p>your survey link <a href=\"{0}\">{0}</a></p>",                                            string.format("{0}answers/fillout?pid={1}",this.getbaseurl(),pinfo.id)),                     isbodyhtml = true                 };                 m.from = new mailaddress("admin@mycompany.com", "administrator"); // placeholder of address i'm sending email                 m.to.add(pinfo.email);                 smtpclient smtp = new smtpclient                 {                     host = "something@somethingelse.net", // placeholder of value of "smtp server" in iis                     port = 25, // value of "port" in iis                     credentials = null,                     enablessl = false                 };                 smtp.send(m);              } catch (exception e) { return json(new { succeeded = false, msg = e.message }); }             // if here, can assume message sent             return json(new { succeeded = true, msg = "thanks! should receive email survey link soon." });         }         else         {             return json(new {                 succeeded = false,                 msg = string.format("oops! there problem in finding info partner {0}", pname)             });         }      } 

and can't figure out exact line since it's run-time error. i've verified pinfo.email when run program valid email address. don't know problem here. ideas? or suggestions how can debug this?


Comments

Popular posts from this blog

Unlimited choices in BASH case statement -

Redirect to a HTTPS version using .htaccess -

javascript - jQuery: Add class depending on URL in the best way -