?
Solved

C# mail

Posted on 2010-09-15
10
Medium Priority
?
482 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
9 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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
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 1000 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
 
LVL 2

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 1000 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
 
LVL 2

Author Comment

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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

839 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