e.g. 3.16 Using the WebMail Helper

chap3
Jason Zhu 2021-07-14 21:49:36 +10:00
parent abbbe0c54d
commit 15363a0ae7
1 changed files with 18 additions and 0 deletions

View File

@ -11,6 +11,24 @@
<title>Thanks</title> <title>Thanks</title>
</head> </head>
<body> <body>
@{
try
{
WebMail.SmtpServer = "smtp.example.com";
WebMail.SmtpPort = 586;
WebMail.EnableSsl = true;
WebMail.UserName = "mySmtpUsername";
WebMail.Password = "mySmtpPassword";
WebMail.From = "rsvp@example.com";
WebMail.Send("party-host@example.com", "RSVP Notification",
Model.Name + " is " + ((Model.WillAttend ?? false) ? "" : "not")
+ "attending");
}
catch (Exception)
{
@:<b>Sorry - we couldn't send the email to confirm your RSVP.</b>
}
}
<div> <div>
<h1>Thank you, @Model.Name</h1> <h1>Thank you, @Model.Name</h1>
@if (Model.WillAttend == true) @if (Model.WillAttend == true)