我使用SMTP发送邮件。现在它正在发送到收件箱的正常邮件消息现在我想要自己的自定义模板与邮件。我已经尝试使用简单的布局自己
@{
ViewBag.Title = "MyLayout";
}
<h2>MyLayout</h2>
在我的联系我们页面
我已经添加了这样的布局
@model Inspinia_MVC5.Models.MailModel
@{
ViewBag.Title = "Index";
@layout = "~/Views/Shared/MyLayout.cshtml";
}
<script src="~/Scripts/jquery-2.1.1.min.js"></script>
<script>
$(document).ready(function () {
$('.summernote').summernote();
if ('@ViewBag.Message' == 'Sent') {
alert('Mail has been sent successfully');
}
$(document).ready(function () {
$('.summernote').summernote();
});
});
</script>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-lg-2">
<div class="ibox float-e-margins">
<div class="ibox-content mailbox-content">
<div class="file-manager">
<div class="row">
<a class="btn btn-block btn-primary compose-mail" href="@Url.Action("ContactUs", "ContactUs")">Compose Mail</a>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-8 animated fadeInRight">
<div class="mail-box-header">
<h2>
Compse mail
</h2>
</div>
<div class="mail-box">
@using (@Html.BeginForm("ContactUs", "ContactUs", FormMethod.Post, new { @id = "form1", @enctype = "multipart/form-data" }))
{
<div class="mail-body">
<form class="form-horizontal" method="get">
<div class="form-group">
<label class="col-sm-2 control-label">To:</label>
<div class="col-sm-10"> <input type="text" name="To" class="form-control" placeholder="Enter your Email Here"></div>
</div>
<br />
<div class="form-group">
<label class="col-sm-2 control-label">Subject:</label>
<div class="col-sm-10"> <input type="text" name="Subject" class="form-control" placeholder="Enter Subject Here"></div>
</div>
<br/>
<br/>
<br />
@*@Html.TextBoxFor(m => m.Subject)*@
<div class="form-group">
<label class="col-sm-2 control-label">Attachment:</label>
<input type="file" name="fileUploader" />
</div>
</form>
<div class="mail-text h-200">
<div class="summernote">
@Html.TextAreaFor(m => m.Body, new { @class = "form-control", style = "width: 840px; height: 139px;" })
<br />
<br />
</div>
<div class="clearfix"></div>
</div>
<div class="mail-body text-right tooltip-demo">
@Html.ValidationSummary()
<input type="submit" class="btn btn-sm btn-primary" data-toggle="tooltip" data-placement="top" value="Send" />
</div>
</div>
}
</div>
</div>
</div>
</div>
@section Styles {
@Styles.Render("~/plugins/summernoteStyles")
@Scripts.Render("~/plugins/summernote")
}
运行代码后我得到像这样的错误
The layout page "= "~/Views/Shared/MyLayout.cshtml";" could not be found at the following path: "~/Views/ContactUs/= "~/Views/Shared/MyLayout.cshtml";"
请任何人告诉如何将自己的模板发送到收件箱
答案 0 :(得分:0)
应该是:
@model Inspinia_MVC5.Models.MailModel
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/MyLayout.cshtml";
}