Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Almacenar las variables necesarias
            string Destino      = textBox1.Text;
            string Asunto       = textBox2.Text;
            string Mensaje      = textBox3.Text;
            string NombreEmisor = textBox4.Text;
            string CorreoEmisor = textBox5.Text;
            string ClaveEmisor  = textBox6.Text;
            //Nueva utilidad, variable para indicar si el correo se envia como html
            bool html = comboBox1.SelectedIndex == 0 ? true : false;
            //Instanciar la librería GoEmail
            GoEmailv2 x = new GoEmailv2();

            //Pasar los parámetros al método Enviar
            //La funcion devuelve BOOL si se envió correctamente
            //Por eso la colocaremos en un IF

            if (x.Enviar(Destino, Asunto, Mensaje, NombreEmisor, CorreoEmisor, ClaveEmisor, html))
            {
                //Notificamos OK
                MessageBox.Show("Enviado correctamente");
            }
            else
            {
                //Notificamos ERROR
                MessageBox.Show("Error: " + GoEmailv2.error);
            }
            //AHORA PODEMOS ENVIAR CORREOS EN FORMATEADOS EN HTML, RECUERDEN:
            //-USAR RUTAS DE IMAGENES EXTERNAS, ej. http://www.imagenes.com/imagen1.jpg
            //-APLICAR ESTILOS CSS  EN LAS ETIQUETAS, ej. <p style='color=red'>Hola</p>
        }
Exemplo n.º 2
0
        public bool EnviarMensaje()
        {
            class_correo correo = new class_correo();
            SmtpClient   client = new SmtpClient();
            GoEmailv2    x      = new GoEmailv2();

            client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "visap2018");
            MailAddress from    = new MailAddress("*****@*****.**", "VisapLine Telecomunicaciones", System.Text.Encoding.UTF8);
            MailAddress to      = new MailAddress(destinatario);
            MailMessage message = new MailMessage(from, to);

            message.Subject = asunto;
            message.Body    = cuerpo;
            string file = archivo;

            if (file != null)
            {
                Attachment data = new Attachment(file, MediaTypeNames.Application.Octet);
                //Add time stamp information for the file.

                ContentDisposition disposition = data.ContentDisposition;
                disposition.CreationDate     = System.IO.File.GetCreationTime(file);
                disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
                disposition.ReadDate         = System.IO.File.GetLastAccessTime(file);
                //Add the file attachment to this e - mail message.
                message.Attachments.Add(data);
            }

            message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
            client.Port      = 587;
            client.Host      = "smtp.gmail.com";
            client.EnableSsl = true;

            try
            {
                if (html)
                {
                    if (file == null)
                    {
                        x.Enviar(destinatario, asunto, cuerpo, "VisapLine Telecomunicaciones", "*****@*****.**", "visap2018", html);
                    }
                    else
                    {
                        string[] arch = new string[1];
                        arch[0] = file;
                        x.EnviarConArchivos(destinatario, asunto, cuerpo, "VisapLine Telecomunicaciones", "*****@*****.**", "visap2018", html, arch);
                    }
                }
                else
                {
                    client.Send(message);
                }
                message.Dispose();
                return(true);
            }
            catch (Exception ex)
            {
                throw new ValidarExeption("Error al enviar el correo", ex);
            }
        }
Exemplo n.º 3
0
        //***************************************************************************************
        //*************************** Enviar Correo  ********************************************
        //***************************************************************************************

        public bool enviar(correo email)
        {
            GoEmailv2 mensaje = new GoEmailv2();

            if (mensaje.Enviar(email.para, email.asunto, email.mensaje, email.nombre, email.correo2, email.contrasena, true))
            {
                return(true);
            }
            else
            {
                string mnsError = GoEmailv2.error;
                return(false);
            }
        }