try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("myUserName@gmail.com");
mail.To.Add("myDestination@yahoo.com");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";
SmtpServer.Port = 465;// 587;
SmtpServer.EnableSsl = true;
SmtpServer.Credentials = new System.Net.NetworkCredential("myUserName", "myPasword");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
Gmail SMTP username: Your Gmail address (for example, example@gmail.com)
Gmail SMTP password: Your Gmail password
Gmail SMTP port (TLS): 587
Gmail SMTP port (SSL): 465
Gmail SMTP TLS/SSL required: Yes
Dann habe ich von dem MimeKit gelesen. Ok nuget nie probiert aber irgendwie installiert. Using using MailKit; using MimeKit; genutzt und dann
private void button2_Click(object sender, EventArgs e)
{//https://www.mimekit.net/docs/html/Creating-Messages.htm
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Herm", "jodahush@gmail.com"));
message.To.Add(new MailboxAddress("mann", "jodahush@yahoo.com"));
message.Subject = "How you doin?";
message.Body = new TextPart("plain")
{
Text = @"Hey Alice,
What are you up to this weekend? Monica is throwing one of her parties on
Saturday and I was hoping you could make it.
Will you be my +1?
-- Joey
"
};
}
Kann man nicht einfach den Standard mail client über c# ansprechen und diesem ein vorausgefülltes mail aus den Rippen leiern? Am liebsten die Windows Mail App. Wie auch immer, mal eben schnell ne mail schicken is wohl eher nicht möglich. Gibt es kein Rezept für Einsteiger?