- 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
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