asp.net - sending email in c# using port no -


i want send email yahoo yahoo bt failed send it. use network received. please review code credential. there no exception or error when mail box opened, there no email. used label show succesfull text, @ time, not showing successfull.

.aspx code:

<form id="form1" runat="server">      message from: <asp:textbox id="text1" runat="server"></asp:textbox>     message to: <asp:textbox id="textbox1" runat="server"></asp:textbox>     message subject: <asp:textbox id="textbox2" runat="server"></asp:textbox>     <asp:button id="b1" runat="server" onclick="click" />     <asp:label id="label1" runat="server" text="label"></asp:label> </form> 

.aspx.cs:

public void click(object sender, eventargs e) {     try     {          //mail message          mailmessage mm = new mailmessage();           //mail address          mm.from = new mailaddress(text1.text);           //emailid send          mm.to.add(textbox1.text);           //your subject line of message          mm.subject = "your subject line go here.";           //now attached file          //mm.attachments.add(new attachment(@"c:\\attachedfile.jpg"));           //add body of email          mm.body = "your body of email.";          mm.isbodyhtml = false;           //smtp           smtpclient smtpserver = new smtpclient();           //your credential go here          smtpserver.credentials = new            system.net.networkcredential("username", "password");           //port number login yahoo server          smtpserver.port = 587;           //yahoo host name          smtpserver.host = "smtp.mail.yahoo.com";          smtpserver.enablessl = true;           smtpserver.send(mm);          label1.text = "successfull";          //send email           //end of try block          //end of catch      }      catch(exception ee){          console.write(ee);      } } 

i don't think code has wrong. use same code yours , works well.

i think there wrong settings, please check:

  1. if recipient's email address in textbox1 has exist
  2. if username , password credentials correct

and don't set port property in code. if right.please show exception info here.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -