locked
WebException can not connect to the remote server RRS feed

  • Question

  • I have a project in a Smart device handheld (Honeywell Dolphin) that sets the data in a SQL Compact database. What I need help is to export the data inserted into the database via an attachment (excel file) in an email.

    Actually  the email I´m handling it´s calling directly from the Smart Device but does not recognizes some libraries like "System.Net.Mail”.  Some one recommended to use the OpenNETCF.Net.Mail  and OpenNETCF.Net libraries, but these do not permit the attachment of  files, so I started to investigate and received advise to do it via website but the problem is that when I make the call from the Smart device and run it from the actual device project, I get the error "WebException: Unable to connect to the remote server" check it and if there is internet which is desecrated.

    The code oft he mail iI´m using is:

    [WebMethod]

        public void Correo()

        {

            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", "Password");

            objeto_mail.From = new MailAddress("email ");

            objeto_mail.To.Add(new MailAddress("email "));

            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();  // here you should be the information in the database

                writer.Flush();

                stream.Position = 0;

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

                client.Send(objeto_mail);

            }

        }

    }

    thanks for your help

    Friday, September 2, 2016 9:10 PM

Answers