Contents tagged with SMTP client

  • How to send email in C# windows forms application

    Hello everybody,

    sometime people ask me how to send email from C# windows forms application or even ask is it possible at all to accomplish in C#?

    I can reassure you that yes, it's possible. 

    For this purpose you can use following code sample:

    private void btnSendMessage_Click(object sender, EventArgs e)

    {

    var from = new MailAddress(txtFrom.Text, "From Name");

    var toEmail = new MailAddress(txtTo.Text, "To Name");

    string passwordFromEmailOfSender = txtPassword.Text;

    string subject = "Subject";

    string body = txtMessage.Text;

    var smtp = new SmtpClient

    {

    Host = "smtp.gmail.com", … more