8
I'm trying to send an email using gmail SMTP in C# using the code bellow
MailMessage message = new MailMessage();
message.To.Add("my email");
message.Subject = "subject";
message.From = new MailAddress("any email");
message.Body = "body";
message.Attachments.Add(new System.Net.Mail.Attachment(path));
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("my user", "my pass");
smtp.Send(message);
When I receive the email, the FROM field is filled with my user. I'm using UseDefaultCredentials as false. When I look to the result, the FROM field is filled with my user. Shouldn't the FROM field be filled with any email? How can I send an email using any email as sender?