WebException It is not possible to connect to the remote server

5

I run my program from the real device and when I execute it, that error comes out, researching that it is due to lack of internet, I verify and the device does have internet, I am developing for Windows Embedded (Windows .Net or Windows Mobile or Windows CE ) and the code of the mail I have it in a website which I make the call from my Smart Device template, I do not know if it would suddenly be more topic that the project does not accept the connection with website.

ERROR: Prueba.exe
WebException
No es posible conectar con el servidor remoto
en System.net.HttpWebRequest.finishGetResponse()
en System.net.HttpWebRequest.GetResponse() 
en System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequestrequest)
en System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequestrequest)
en System.web.sercices.Protocols.SoapHttpWebClientProtocol.doInvokes(string methodName,Object[] parameters,WebClientAsyncResult AsyncResult) en Prueba.localhost.service.correo()

as the mail code on the website is this

MailMessage objeto_mail = new MailMessage();
    SmtpClient client = new SmtpClient();
    client.Port = 25;
    client.Host = "smtp.live.com";
    client.Timeout = 100000000;
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.UseDefaultCredentials = false;
    client.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
    objeto_mail.From = new MailAddress("[email protected]");
    objeto_mail.To.Add(new MailAddress("[email protected]"));
    objeto_mail.Subject = "Pedidos";

    List<string> Archivo = new List<string>();
    Archivo.Add("");
    Archivo.Add("");

    objeto_mail.IsBodyHtml = false;
    objeto_mail.Body = "se hizo el pedido y la orden esta adjuntada en el correo con un excell";
    client.EnableSsl = true;


    using (var stream = new MemoryStream())
    using (var writer = new StreamWriter(stream))    
    {

        writer.WriteLine();
        writer.Flush();
        stream.Position = 0;     

        objeto_mail.Attachments.Add(new Attachment(stream, "Pedido.cvs", "text/csv"));

        client.Send(objeto_mail);
    }

and in the Smart Device template I do it in the following way

localhost.Service obj = new Prueba.localhost.Service();

        obj.Correo();
    
asked by Cristian R.M 01.09.2016 в 15:11
source

1 answer

2

I do not think you can connect to smp.live.com through port 25.

Try with:

client.Port = 587;
client.EnableSsl = true;

link

    
answered by 29.12.2016 в 16:57