Solved

C# mail

Posted on 2010-09-15
10
474 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

13 Experts available now in Live!

Get 1:1 Help Now