Email from C# windows application

Discussion in 'C#' started by mymindrules, Sep 23, 2013.

  1. #1
    Hello People

    I want to send email from windows desktop application which I am creating in visual studio using language c#. Can anyone tell me how can i send email using windows app?
     
    mymindrules, Sep 23, 2013 IP
  2. seotraining

    seotraining Active Member

    Messages:
    511
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    70
    #2
    You can use gmail api for it here is the code for it
    MailMessage m = new MailMessage("mailidofSender", To);
                m.Subject = Subject;
                m.Body = Body;
                m.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "mail.google.com";
                NetworkCredential authinfo = new NetworkCredential("mailidfrom", "YourPassword");
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = authinfo;
                smtp.Send(m);
    
    Code (markup):
     
    seotraining, Sep 24, 2013 IP
    mymindrules likes this.