Unable to send mail using System.Net.Mail
- From: "Kaustav." <Kaustav.@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 13 Sep 2005 00:03:03 -0700
Hi,
I am trying to send a mail using the System.Net.Mail namespace. My SMTP
server requires authentication and the following is the code snippet which
I've been using:
MailMessage msg = new MailMessage();
SmtpClient server = new SmtpClient();
System.Net.NetworkCredential credentials = new
System.Net.NetworkCredential(Username, Password);
msg.From = new MailAddress(From, DisplayName);
msg.To.Add(To);
msg.CC.Add(Cc);
msg.Bcc.Add(Bcc);
msg.Subject = Subject;
msg.Body = Body;
msg.IsBodyHtml = true;
server.Host = SMTPServer;
server.UseDefaultCredentials = false;
server.Credentials = credentials;
server.Send(msg);
I get an exception which says
"A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond".
I have tried increasing the timeout and that too didn't help. I am using VS
2005 Beta 2 on a W2K3 Server Standard Edition.
Any inputs will be much appreciated. Thanks.
.
- Follow-Ups:
- Re: Unable to send mail using System.Net.Mail
- From: Lau Lei Cheong
- Re: Unable to send mail using System.Net.Mail
- Prev by Date: RE: Bug in FileStream.Dispose in Framework 1.1
- Next by Date: return statement inside finally block
- Previous by thread: WMI Connection via diferent port
- Next by thread: Re: Unable to send mail using System.Net.Mail
- Index(es):
Relevant Pages
|