Solved

C# mail

Posted on 2010-09-15
10
475 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
 
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
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 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

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
New to SOAP and need some direction 10 45
Export import database 4 43
.Net Web Site IIS Web.Config Content-Security-Policy 1 43
Close form "before" open 3 25
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

23 Experts available now in Live!

Get 1:1 Help Now