Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# mail

Posted on 2010-09-15
10
Medium Priority
?
481 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 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