I have 2 "Send mail as" in my Gmail account:
On my C# code I have this:
MailAddress from = new MailAddress("[email protected]", "Contact");
MailAddress to = new MailAddress("[email protected]");
MailMessage message = new MailMessage(from, to);
message.Subject = "Subject";
message.From = new MailAddress("[email protected]");
SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com";
client.Port = 587;
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("[email protected]", "password");
client.Send(message);
The address [email protected]
is a group of addresses in GSuit
.
Even using 2 "From" in "MailMessage" I couldn't send emails from my secondary address, it keeps sending from my main ([email protected]
)
If I try to compose an email in my Gmail account I can choose my secondary address and send an email.