How to send an email with ASP.net 2.0?

W

Wells Wang

Hi, Everybody:

Sorry to bother you.

I am trying to use the code below to send an email with asp.net2.0& win
XP. But it failed. On my laptop I can use outlook2003 to send email. If
you are avaiable, could you help me figure it out(or test it on you
computer).

I am looking forward to getting any feedback from you.I can be reached
at (e-mail address removed).

Thanks in advance and have a nice weekend.

Wells

======== source code ==============================
SmtpClient smtp = new SmtpClient();
smtp.Host = ¡°smtp.gmail.com¡±;
smtp.Port = 465;

smtp.Credentials = new System.Net.NetworkCredential(¡±uid¡±, ¡°pwd¡±);
smtp.EnableSsl = true;
System.Net.Mail.MailMessage message = new
MailMessage(¡±[email protected]¡±, ¡°[email protected]¡±, ¡°Subject¡±,
¡°Body¡±);
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
try
{
smtp.Send(message);
Response.Write(¡±Email successfully sent.¡±);
}
catch (Exception ex)
{
Response.Write(¡±Send Email Failed.¡± + ex.ToString()); ;
}


======== Exception ====================================
Send Email Failed.System.Net.Mail.SmtpException: The operation has timed
out. at System.Net.Mail.SmtpClient.Send(MailMessage message) at
MainPage.Button1_Click(Object sender, EventArgs e) in c:\Programming in
Class\ThreePages\MainPage.aspx.cs:line 111
 
G

Guest

Hi, Everybody:

Sorry to bother you.

I am trying to use the code below to send an email with asp.net2.0& win
XP. But it failed. On my laptop I can use outlook2003 to send email. If
you are avaiable, could you help me figure it out(or test it on you
computer).

I am looking forward to getting any feedback from you.I can be reached
at (e-mail address removed).

Thanks in advance and have a nice weekend.

Wells

======== source code ==============================
SmtpClient smtp = new SmtpClient();
smtp.Host = ¡°smtp.gmail.com¡±;
smtp.Port = 465;

smtp.Credentials = new System.Net.NetworkCredential(¡±uid¡±, ¡°pwd¡±);
smtp.EnableSsl = true;
System.Net.Mail.MailMessage message = new
MailMessage(¡±[email protected]¡±, ¡°[email protected]¡±, ¡°Subject¡±,
¡°Body¡±);
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
try
{
smtp.Send(message);
Response.Write(¡±Email successfully sent.¡±);}

catch (Exception ex)
{
Response.Write(¡±Send Email Failed.¡± + ex.ToString()); ;

}

======== Exception ====================================
Send Email Failed.System.Net.Mail.SmtpException: The operation has timed
out. at System.Net.Mail.SmtpClient.Send(MailMessage message) at
MainPage.Button1_Click(Object sender, EventArgs e) in c:\Programming in
Class\ThreePages\MainPage.aspx.cs:line 111

*** Sent via Developersdexhttp://www.developersdex.com***


Indicate port 587 and then it should work fine.
 

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