0

I' am developing simple windows form application using C#. in this case I need to send email using this application. And in this time I already configured Mozilla Thunderbird as default mail client. My code requires default mail client smtp host and credentials. therefore I need to get these things from windows default mail client.

My Code:

    MailMessage mail = new MailMessage();

    //set the addresses
    mail.From = new MailAddress("example@gmail.com");
    mail.To.Add("example1@gmail.com");

    //set the content
    mail.Subject = "sampleSubject";
    mail.Body = "sampleBody";

    //add an attachment from the filesystem
    mail.Attachments.Add(new Attachment(filePath));

    //send the message
    SmtpClient smtp = new SmtpClient("smtpHOst");
    smtp.Credentials = new NetworkCredential("username", "password");
    smtp.Send(mail);
  • I think the mail client does not store the credentials. The windows credentials manager will be used here... https://stackoverflow.com/questions/29214288/access-windows-credentials-in-credential-manager – Chetan Aug 11 '21 at 09:51
  • thanks chetan. I will try that. – Neo Biz Aug 11 '21 at 11:42

0 Answers0