有谁知道如何更改代码中的发件人电子邮件地址以覆盖 web.config 设置。
我正在尝试做的是允许某人填写在线表格,当收件人收到电子邮件时,它将来自发件人的电子邮件地址。
但目前它只是在 web.config 中显示默认值。
-----------------Web.config----------
<smtp from="some-email@gmail.com" deliveryMethod="SpecifiedPickupDirectory">
<network host="localhost" />
<specifiedPickupDirectory pickupDirectoryLocation="c:\temp\"/>
</smtp>
public virtual MvcMailMessage DirectotyEmail(string emailTo, string fromName, string arrivalDate, string departureDate, string message)
{
ViewBag.FromName = fromName;
ViewBag.ArrivalDate = arrivalDate;
ViewBag.DepartureDate = departureDate;
ViewBag.Message = message;
return Populate(x =>
{
x.Subject = "Accommodation Enquery form";
x.ViewName = "DirectoryEmail";
x.To.Add(emailTo.ToString());
//x.From.Address("test@email.com");
x.IsBodyHtml = true;
});
}
X-Sender: some-email@gmail.com << Need this to be the email that user entered when submitting form
X-Receiver: test@mail.com
MIME-Version: 1.0
From: some-email@gmail.com << Need this to be the email that user entered when submitting form
To: test@mail.com
Date: 26 Mar 2013 11:08:57 +0000
Subject: Accommodation Enquery form
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable