2016-03-03 69 views
0
@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 protected]", "Client"); 
     MailAddress to = new MailAddress("[email protected]", "Admin"); 
     MailMessage mail = new MailMessage(from,to); 
     SmtpClient client = new SmtpClient(); 
     client.Host = "my1.hosting.com"; 
     client.Credentials = new System.Net.NetworkCredential("[email protected]", "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> 

上面的代碼只發送到電子郵件....ASP.NET C#一把umbraco 7 - 形式發送電子郵件和保存到DB

,它的工作...

,但我想發送電子郵件,也保存到數據庫...

是否有任何插件umbraco的形式,使其變得簡單?

我想在管理面板的某處查看列表中提交的表單。

回答

2

有一種名爲Umbraco Forms的付費解決方案,可以滿足您的要求嗎?