Hi,
This is a follow-on to a previous thread, where I was having trouble sending
mail via smtp.gmail.com. Here is the code which works properly:
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Credentials = new NetworkCredential("[email protected]",
"password");
client.Timeout = 5000;
MailMessage message = new MailMessage();
message.IsBodyHtml = false;
message.From = new MailAddress("[email protected]");
message.To.Add("[email protected]");
message.Subject = "The Subject";
message.Body = "this is the body";
try
{
client.Send(message);
}
catch (Exception ex) { // do something }
Except - when the mail arrives, the From is the username passed in as a
credential, [email protected]. Instead, I want the From to be the
e-mail address explicitly set as [email protected]. How do I get the
message.From to be correct? When stepping through the code in the debugger,
Intellisense reports that message.From is what I want, not what actually
shows up.
Thanks.
Dan
--
You received this message because you are subscribed to the Google Groups
"Google Apps Domain Information and Management APIs" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-apps-mgmt-apis/-/9wvFkwCbFcIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-apps-mgmt-apis?hl=en.