发送时未填充整个电子邮件 - 邮政,MVC 5

Entire email not being populated when sent - Postal, MVC 5

我正在使用邮政图书馆从我正在工作的网站上的联系页面发送电子邮件,它发送了电子邮件,但并非所有项目都包含在电子邮件中。我在代码中放置了一个断点并逐步执行代码,所有项目都在正在传递的模型中,但是通过电子邮件发送的模板没有所有数据。

这是简单的模板 (Contact.cshtml):

@model AccessorizeForLess.Models.ContactEmail
To: ****************@psychocoder.net
From: @Model.From
First Name: @Model.FirstName
Last Name: @Model.LastName
Subject: @Model.SelectedSubject
Message: @Model.Message

这是 ContactEmail 模型

using AccessorizeForLess.ViewModels;
using Postal;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AccessorizeForLess.Models
{
    public class ContactEmail : Email
    {
        public string To { get; set; }

        [DataType(DataType.EmailAddress)]
        [DisplayName("Email Address")]
        [RegularExpression(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$", ErrorMessage = "Please enter a valid email address!")]
        [Required(ErrorMessage="Please provide your email address")]
        public string From { get; set; }

        [DisplayName("First Name")]
        [Required(ErrorMessage="Please provide your first name")]
        public string FirstName { get; set; }

        [DisplayName("Last Name")]
        [Required(ErrorMessage="Please provide your last name")]
        public string LastName { get; set; }

        [DisplayName("Subject")]
        [Required(ErrorMessage="Please select a subject")]
        public string SelectedSubject { get; set; }

        [DisplayName("Message")]
        [DataType(DataType.MultilineText)]
        [Required(ErrorMessage="Please provide a message for the email")]
        public string Message { get; set; }

        public List<EmailSubjectViewModel> Subjects { get; set; }
    }
}

以及 ContactController 中的 Send 方法:

public ActionResult Send(ContactEmail email)
{
    ContactEmail e = new ContactEmail();
    e.From = email.From;
    e.FirstName = email.FirstName;
    e.LastName = email.LastName;
    e.SelectedSubject = email.SelectedSubject;
    e.Message = email.Message;

    e.Send();
    return RedirectToAction("Index");
}

我已经完成 Send 并且正在传递的模型包含所有数据,但到达的电子邮件只有姓氏、主题和消息。由于某种原因缺少名字和电子邮件地址。

我将 Contact.cshtml(我的电子邮件模板)更改为如下所示,现在正在填充所有内容

 Content-Type: text/html; charset=utf-8  
@model AccessorizeForLess.Models.ContactEmail
To: **************@psychocoder.net
From: @Model.From


<html>
    <head>
        <title>Email from @Model.From</title>
        <style>
            hr
            {
               border: 1px solid #e50e8d;
               box-shadow: 5px 5px 5px #888888;
            }
        </style>
    </head>
<body>
    <p>Dear Admin, you have received an email from @Model.FirstName  @Model.LastName regarding @Model.SelectedSubject .</p>
    <p>The content of the message is below:<br />
    <hr />
    Message: @Model.Message<br />
    <hr /></p>
</body>
</html>