private void button1_Click(object sender, EventArgs e)
{
if (check() == true) // True: sends mail
{
try
{
// Mailmessage wordt gedeclareerd (hiermee kan je mails sturen)
MailMessage mail = new MailMessage();
// SMTP server van GMAIL wordt hier aangegeven
SmtpClient smtpali = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "Test Mail";
mail.Body = "Beste gebruiker";
smtpali.Port = 587;
smtpali.Credentials = new NetworkCredential("user", "xxxxxxx");
smtpali.EnableSsl = true;
smtpali.Send(mail);
MessageBox.Show("Mail is verzonden!");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
else
{
MessageBox.Show("Verkeerde combinatie!");
}
}
大家好。我在C#中創建了一個登錄系統,並剛剛完成「重發密碼」表單。這個表格用他的密碼發送一封郵件給用戶(簡單明瞭)。我想知道,我可以用什麼方式HTML標記在身:郵件中的HTML標記
mail.Body = "content here"
我試着使用:
mail.Body = "<h1>content here</h1>"
...等,不過是ofcourse純文本。對我的情況有什麼建議?
感謝,並獲得成功!對不起,問一個簡單的問題。 – 2013-03-27 15:39:45