I want to send a mail from my asp.net web application,here I am using same from and to address,for testing
I am using webmail.1and1.com for my outlook.
I am not having gmail in my system,and smtp also is not configured,
so the following code is not work
protected void btnsubmit_Click(object sender, EventArgs e)
{
Response.Write("you have applied" + ddl.SelectedItem.ToString());
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
mm.To.Add(new System.Net.Mail.MailAddress("iyalarasi.r@winxsolutions.com"));
mm.From = new System.Net.Mail.MailAddress("iyalarasi.r@winxsolutions.com");
mm.Sender = new System.Net.Mail.MailAddress("iyalarasi.r@winxsolutions.com");
mm.Subject = "Request for Leave";
mm.Body = txteno .Text+"request"+ddl.SelectedItem .ToString ()+"leave";
mm.IsBodyHtml = true;
mm.Priority = System.Net.Mail.MailPriority.High;
System.Net.Mail.SmtpClient smtCliend = new System.Net.Mail.SmtpClient();
smtCliend.Host = "pop.1and1.com";
smtCliend.Port = 25;
smtCliend.Credentials = new NetworkCredential("User Name", "Password");
smtCliend.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
try
{
smtCliend.Send(mm);
}
catch (System.Net.Mail.SmtpException ex)
{
lblmsg.Text = ex.ToString();
}
catch (Exception exe)
{
lblmsg.Text = "\n\n\n" + exe.ToString();
}
}
It shows the error as,
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 74.208.5.5:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) 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(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) 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 _Default.btnsubmit_Click(Object sender, EventArgs e) in d:\15\WebLeave\Default.aspx.cs:line 37
give me some links that how to send an email using webmail.1and1.com
Please help me soon.
Thanks in advance.