Source

mvc-book-demo / PartyInvites / Views / Home / Thanks.cshtml

Full commit
@model PartyInvites.Models.GuestResponse

@{
    try
    {
        WebMail.SmtpServer = "smtp.example.com";
        WebMail.SmtpPort = 587;
        WebMail.EnableSsl = true;
        WebMail.UserName = "username";
        WebMail.Password = "password";
        WebMail.From = "yo@mtvraps.com";

        WebMail.Send("test@go.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>
    }           
}

<!DOCTYPE html>

<html>
<head>
    <title>Thanks</title>
</head>
<body>
    <div>
        <h1>Thank you, @Model.Name!</h1>
        @if (Model.WillAttend == true) {
            @:It's great that you're coming. The drinks are already in the fridge!
        } else {
            @:Sorry to hear that you can't make it, but thanks for letting us know.
        }
    </div>
</body>
</html>