Solved

C# mail

Posted on 2010-09-15
10
476 Views
Last Modified: 2012-05-10
i am getting below Error

The transport failed to connect to the server.

Please see below my coding
protected void Page_Load(object sender, EventArgs e)
    {

        try
        {
            MailMessage mail = new MailMessage();
            mail.To = "di1111@yahoo.com";
            mail.From = "test12345@yahoo.com";
            mail.Subject = "this is a test email.";
            mail.Body = "Some text goes here";
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");      //basic authentication
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "testuser"); //set your username here
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123");      //set your password here

            SmtpMail.SmtpServer = "smtpout.europe.secureserver.net";  //your real server goes here
            SmtpMail.Send(mail);



        }
        catch (Exception ie)
        {

            Response.Write(ie.Message);
        }
    }

Can any show me where iam doing the mistake.
0
Comment
Question by:lankapala
  • 2
  • 2
  • 2
  • +2
10 Comments
 
LVL 1

Expert Comment

by:nil1st
ID: 33687479
Are you behind firewall? try turning firewall off.
0
 
LVL 1

Expert Comment

by:nil1st
ID: 33687493
0
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 33687765
Please make sure your server IP address is added to the gateway or firewall. We had the same prblm and we contacted the admin he added our servers Ip address to the gateway. Then the mail sending option is good to go ....I thnk this is not the coding issue this is a permission issue.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 33687770
just try this


replace the below line 
SmtpMail.SmtpServer = "smtpout.europe.secureserver.net"; 

with

SmtpMail.SmtpServer.Insert(0, "smtpout.europe.secureserver.net");

Open in new window

0
 
LVL 7

Assisted Solution

by:Element1910
Element1910 earned 250 total points
ID: 33687792
That error message is relating to it not being able to connect to your mail server. Make sure you've typed in your mail server correctly. Do you require email authentication to this or did you get this code from a tutorial?

Try this and replace the fields you need to with your information and see if it works:

try
            {
                MailMessage mail = new MailMessage();

                mail.From = new MailAddress("test12345@yahoo.com");
                mail.To.Add("di1111@yahoo.com");

                mail.Subject = "this is a test email";
                mail.Body = "Some text goes here";
                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient("server or IP.com", 25);
                smtp.Send(mail);
            }
            catch (Exception ie)
            {
                Response.Write(ie.Message);
            }

Open in new window

0
 
LVL 1

Expert Comment

by:Harvey
ID: 33688753
I think your program works with Exchange server with CDO only.  If the targeted SMTP server is not exchange, it won't work.  Like Element1910: said, use SmtpClient.  MSDN says the SmtpMail is obosolete anyway.  I have similar program using SmtpClient working.

If it still doesn't work, this should be related to your network.

Test your connection to the port 25 on the SMTP server by telnet.

    telnet smtpout.europe.secureserver.net 25

If telnet works but the program doesn't work, you need to do a network capture.  Post the network trace here and I can analyze for you.
0
 

Author Comment

by:lankapala
ID: 33697023
hi i try
type using my computer below command
telnet smtpout.europe.secureserver.net 25
its showing 220*********

I brought my web space(ASP.net ) from Godady.com.
Other all above examples are not working.
0
 
LVL 1

Accepted Solution

by:
Harvey earned 250 total points
ID: 33697066
Please try this one.  I think you also need to set the Credentials when using SmtpClient.

If that doesn't work, please download WireShark and see if you can get a network trace for me.
string to = "di1111@yahoo.com";
            string from = "test12345@yahoo.com";
            string subject = "Using the new SMTP client.";
            string body = @"Using this new feature, you can send an e-mail message from an application very easily.";
            MailMessage message = new MailMessage(from, to, subject, body);

            SmtpClient client = new SmtpClient("smtpout.europe.secureserver.net");
            client.Credentials = new System.Net.NetworkCredential("testuser", "123");
            client.UseDefaultCredentials = false;

            client.Send(message);

Open in new window

0
 

Author Comment

by:lankapala
ID: 33925282
no idea still its not working
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now