Unable to send mail using System.Net.Mail



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.

.



Relevant Pages

  • RE: Remote Desktop Connection (Terminal Services Client 6.0)
    ... When a domain is not presented for the username, ... the server name entered was ... into the credentials dialog. ... Vista Remote Desktop Connection Authentication FAQ ...
    (microsoft.public.windows.terminal_services)
  • Re: Outgoing POP3 email missing/lost/not received
    ... Funny thing is that I have had this ISP for 8 years and it has always been ... It looks like when you last ran CEICW, you set the ISP's mail server to: ... Internet Connection Wizard. ... After the wizard completes, the following network connection ...
    (microsoft.public.windows.server.sbs)
  • Re: Cannot connect client to server 2003
    ... you need to reconfigure the IP schema of your SBS ... On the SBS 2003 Server open the Server Management console. ... On the Connection Type page, click Broadband, and then click Next. ... Alternate DNS server, type the IP addresses that are provided by your ISP ...
    (microsoft.public.windows.server.sbs)
  • Re: Outgoing POP3 email missing/lost/not received
    ... ISP's mail server instead of the domain name on the ... SUMMARY OF SETTINGS FOR CONFIGURE E-MAIL AND INTERNET ... Internet Connection Wizard. ... After the wizard completes, the following network connection ...
    (microsoft.public.windows.server.sbs)
  • Re: Networking Question - VLANs on SBS 2003 Premium SP1
    ... port on the old router so I now have a segregated WLAN. ... be sure you do not enable any DHCP server in internal network. ... On the Connection Type page, click Broadband, and then click Next. ... On the Network Connection, You must enable and configure the network ...
    (microsoft.public.windows.server.sbs)