I'm sending emails from my winforms app by using the MailMessage functionality.
I compile the email, save it to disk and then the default mail client will open the mail for the user to verify the settings before hitting Send.
I want to set the 'From' of the email automatically to the default email account as set up in the mail client. How can I do that?
var mailMessage = new MailMessage();
mailMessage.From = new MailAddress(fromEmailAccount);
mailMessage.To.Add(new MailAddress("recipient@work.com"));
mailMessage.Subject = "Mail Subject";
mailMessage.Body = "Mail Body";
If I leave fromEmailAccount
blank I get an error, and if I set it to something like 'test@test.com' the email does not send as the local account does not have permissions to send it via an unknown account.