system.net.mail.smtpexception "The operation has timed out"

Joined
Jul 29, 2008
Messages
1
Reaction score
0
i am sending mail using asp.net and my code is

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;


public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
SmtpClient client = new SmtpClient();
client.Host = "hostname";
client.Port = 2095;
client.Credentials = new System.Net.NetworkCredential("username", "password");
//client.EnableSsl = true;
//client.Timeout = 10000;


MailAddress from = new MailAddress("(e-mail address removed)");
MailAddress to = new MailAddress("(e-mail address removed)");

Attachment att1 = new Attachment("d:\\1.pdf");
MailMessage msg = new MailMessage(from, to);

msg.Subject = "Mail Test Success...";
msg.Attachments.Add(att1);
msg.Body = "some text for message body";
try
{
client.Send(msg);
Response.Write("<script> alert('Mail Was Sent Successfully...') </script>");
}
catch (Exception ex)
{
Response.Write("<script> alert('" + ex.toString() + "') </script>");
}
}
}

after execution i am getting error

system.net.mail.smtpexception "The operation has timed out"

can any one help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top