-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml
38 lines (32 loc) · 1.28 KB
/
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 1.html
// create email message
var email = new MimeMessage();
email.From.Add(MailboxAddress.Parse("[email protected]"));
email.To.Add(MailboxAddress.Parse("[email protected]"));
email.Subject = "Test Email Subject";
email.Body = new TextPart(TextFormat.Html) { Text = "<h1>Example HTML Message Body</h1>" };
// send email
using var smtp = new SmtpClient();
smtp.Connect("smtp.ethereal.email", 587, SecureSocketOptions.StartTls);
smtp.Authenticate("[USERNAME]", "[PASSWORD]");
smtp.Send(email);
smtp.Disconnect(true);
// 2.text
// create email message
var email = new MimeMessage();
email.From.Add(MailboxAddress.Parse("[email protected]"));
email.To.Add(MailboxAddress.Parse("[email protected]"));
email.Subject = "Test Email Subject";
email.Body = new TextPart(TextFormat.Plain) { Text = "Example Plain Text Message Body" };
// send email
using var smtp = new SmtpClient();
smtp.Connect("smtp.ethereal.email", 587, SecureSocketOptions.StartTls);
smtp.Authenticate("[USERNAME]", "[PASSWORD]");
smtp.Send(email);
smtp.Disconnect(true);
// gmail
smtp.Connect("smtp.gmail.com", 587, SecureSocketOptions.StartTls);
// hotmail
smtp.Connect("smtp.live.com", 587, SecureSocketOptions.StartTls);
// office 365
smtp.Connect("smtp.office365.com", 587, SecureSocketOptions.StartTls);