I have 2 "Send mail as" in my Gmail account:
On my C# code I have this:
MailAddress from = new MailAddress("second@domain.org", "Contact");
MailAddress to = new MailAddress("myotheremail@domain.org");
MailMessage message = new MailMessage(from, to);
message.Subject = "Subject";
message.From = new MailAddress("second@domain.org");
SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com";
client.Port = 587;
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("first@domain.org", "password");
client.Send(message);
The address second@domain.org
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 (first@domain.org
)
If I try to compose an email in my Gmail account I can choose my secondary address and send an email.