ASP.NET C#Umbraco 7 - 表格发送电子邮件&保存到DB

时间:2016-03-03 07:44:48

标签: c# asp.net forms umbraco

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Net.Mail
@{
    Layout = "Master.cshtml";
}
@{
    var fullname="";
    var mobileno="";
    var email="";

    if (IsPost){
        fullname=!Request["fullname"].IsEmpty()?Request["fullname"]:"";
        mobileno=!Request["mobileno"].IsEmpty()?Request["mobileno"]:"";
        email=!Request["email"].IsEmpty()?Request["email"]:"";

        MailAddress from = new MailAddress("email@email.com", "Client");
        MailAddress to = new MailAddress("receiver@email.com", "Admin"); 
        MailMessage mail = new MailMessage(from,to);
        SmtpClient client = new SmtpClient();
        client.Host = "my1.hosting.com";
        client.Credentials = new System.Net.NetworkCredential("email@email.com", "passwordemail");
        client.Port = 2525;

        mail.IsBodyHtml = true;

        mail.Subject = "Submitted Form by "+fullname;

        mail.Body += "<strong>Full Name</strong> : "+fullname;
        mail.Body += "<br /><strong>Mobile No</strong> : "+mobileno;
        mail.Body += "<br /><strong>Email Address</strong> : "+email;

        client.Send(mail);
    }
}
<form method="POST">
    <label>Full Name</label>
    <input type="text" class="form-control" name="fullname" >

    <label>Mobile No.</label>
    <input type="text" class="form-control" name="mobileno" >

    <label>Email Address</label>
    <input type="email" class="form-control" name="email" >

    <input type="submit" id="af-assist-submitBtn" value="Submit Now!"/>
</form>

上面的代码只发送到电子邮件....

它正在工作......

但我想发送电子邮件并保存到数据库......

是否有任何umbraco插件可以使表单变得简单?

我希望在管理面板的某个位置查看列表中提交的表单。

1 个答案:

答案 0 :(得分:2)

有一种名为Umbraco Forms的付费解决方案可以满足您的要求吗?