How to send a mail using C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamil abou khalil
    New Member
    • Oct 2006
    • 3

    How to send a mail using C#

    Hi all,

    I need to know how to authenticate a user before sending a mail using a
    C# application.

    The source code i use is this:

    private void sendMailButton_ Click(object sender, EventArgs e)
    {
    try
    {
    MailMessage mailMessage = new
    MailMessage(toT extBox.Text, fromTextBox.Tex t, subjectTextBox. Text,
    bodyTextBox.Tex t);

    SmtpClient obj = new SmtpClient(SMTP TextBox.Text);
    obj.Send(mailMe ssage);
    MessageBox.Show ("Message Sent");

    }
    catch (Exception ex)
    {
    MessageBox.Show ("message not sent");

    }
    }

    I need to add the authentication part. This is working but with no
    authentication for the user or the mail sender address. I am using a
    local SMTP server.
    Thanks,
Working...