elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  mail
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: mail  (Leído 1,683 veces)
louisozu

Desconectado Desconectado

Mensajes: 1


Ver Perfil
mail
« en: 2 Septiembre 2010, 01:33 am »

hola alguien me puede ayudar como puedo enviar email
ya sea utilizando dos o vb


En línea

.mokk.

Desconectado Desconectado

Mensajes: 177



Ver Perfil
Re: mail
« Respuesta #1 en: 2 Septiembre 2010, 04:02 am »

Código
  1. using System;
  2. using System.Collections;
  3. using System.Net;
  4. using System.Net.Mail;
  5. using System.Net.Mime;
  6.  
  7. public class EjemploCorreoGMail
  8. {
  9.    public static void Main()
  10.    {
  11.            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
  12.            msg.To.Add("destinatario@dominio.com");
  13.            msg.From = new MailAddress("micuenta@gmail.com", "Tu Nombre", System.Text.Encoding.UTF8);
  14.            msg.Subject = "Prueba de correo a GMail";
  15.            msg.SubjectEncoding = System.Text.Encoding.UTF8;
  16.            msg.Body = "Cuerpo del mensaje";
  17.            msg.BodyEncoding = System.Text.Encoding.UTF8;
  18.            msg.IsBodyHtml = false;
  19.  
  20.            //Aquí es donde se hace lo especial
  21.            SmtpClient client = new SmtpClient();
  22.            client.Credentials = new System.Net.NetworkCredential("micuenta@gmail.com", "miclave");
  23.            client.Port = 587;
  24.            client.Host = "smtp.gmail.com";
  25.            client.EnableSsl = true; //Esto es para que vaya a través de SSL que es obligatorio con GMail
  26.            try
  27.            {
  28.                        client.Send(msg);
  29.            }
  30.            catch (System.Net.Mail.SmtpException ex)
  31.            {
  32.                        Console.WriteLine(ex.Message);
  33.                        Console.ReadLine();
  34.            }
  35.    }
  36. }

Credits: José M. Alarcón Aguín


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Atomic mail sender
Software
huerto123 1 2,361 Último mensaje 20 Noviembre 2021, 23:54 pm
por Machacador
mail desviado
Hacking
leirego 0 1,197 Último mensaje 13 Julio 2023, 01:02 am
por leirego
Mail.com
Dudas Generales
B€T€B€ 0 842 Último mensaje 3 Octubre 2023, 21:54 pm
por B€T€B€
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines