Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
try
      {
          SmtpClient emailClient = new SmtpClient("smtp.mail.yahoo.com");
          System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("nasimbahar78@yahoo.com","myyahoopassword");
          emailClient.EnableSsl = true;
          emailClient.Credentials = SMTPUserInfo;
          emailClient.Port = 995;


          System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("nasimbahar78@yahoo.com", "nasimbahar78@another.com", "fire!!", "Call up 911 and inform my house is on fire and my phone too");
          message.Priority = System.Net.Mail.MailPriority.High;
          emailClient.Send(message);
      }
      catch (Exception ee)
      {
          lblerror.Text = ee.ToString();


      }




below is my excpetion
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 188.125.69.59:995 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at annoncemeeting.Button3_Click(Object sender, EventArgs e) in c:\Users\Mohammad Nasim\Documents\Visual Studio 2010\WebSites\WebSite4\annoncemeeting.aspx.cs:line 103
Posted

1 solution

Hey there are links
Send Email using SMTP in C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900