none
Enviar mail con c# RRS feed

  • Pregunta

  • hola a todos, durante dias he intentado enviar un mail por c#, desde un windows form pero no puedo hacer, revice muchos links y nada, me manda una excepcion y el mensaje es el siguiente:
    The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at                             

    Bueno y mi código es el sgte:

    using

    System;

    using

    System.Collections.Generic;

    using

    System.ComponentModel;

    using

    System.Data;

    using

    System.Drawing;

    using

    System.Text;

    using

    System.Windows.Forms;

    using

    System.Net.Mail;

    using

    System.Web;

    using

    System.Net;

    namespace

    Enviar_Email

     

    public partial class Form1 : Form

    {

     

    public Form1()

     

    private void Form1_Load(object sender, EventArgs e)

     

    private void button1_Click(object sender, EventArgs e)

     

    MailMessage msg = new System.Net.Mail.MailMessage();

    msg.To.Add(

     

    "josemega123@gmail.com");

    msg.From =

     

    new System.Net.Mail.MailAddress("josemega123@gmail.com", "Many Doctors Administrator", System.Text.Encoding.UTF8);

     

    "Mail de prueba";

    msg.SubjectEncoding = System.Text.

     

    Encoding.UTF8;

    msg.Body =

     

    "Cualquier cosa";

    msg.BodyEncoding = System.Text.

     

    Encoding.UTF8;

    msg.IsBodyHtml =

     

    true;

    System.Net.Mail.

     

    SmtpClient client = new System.Net.Mail.SmtpClient();

    client.Credentials =

     

    new System.Net.NetworkCredential("josemega123@gmail.com", "mipassword");

     

    "smtp.gmail.com";

    client.EnableSsl =

     

    true;

     

     

    try

    {

    client.Send(msg);

    }

     

    catch (Exception ex)

     


    Serg

    {

    textBox1.Text = ex.Message;

    }

    }

    }

    }

    client.Port = 587;

    client.Host =

     

    msg.Subject =

    {

    System.Net.Mail.

    {

    }

     

    {

    InitializeComponent();

    }

     

    {

     

    martes, 11 de agosto de 2009 23:09

Todas las respuestas