- private void button1_Click(object sender, EventArgs e)
- {
- MailMessage mail = new MailMessage();
- NetworkCredential cred = new NetworkCredential("帳號@tech.com.tw", "密碼");
- //收件者
- mail.To.Add("mess@gmail.com");
- mail.Subject = "subject";
- //寄件者
- mail.From = new System.Net.Mail.MailAddress("mess@gmail.com");
- mail.IsBodyHtml = true;
- mail.Body = "message";
- //設定SMTP
- SmtpClient smtp = new SmtpClient("smtp.gmail.com");
- smtp.UseDefaultCredentials = false;
- smtp.EnableSsl = true;
- smtp.Credentials = cred;
- smtp.Port = 587;
- //送出Mail
- smtp.Send(mail);
- }
沒有留言:
張貼留言