剃须刀网页上的SMTP

时间:2018-05-22 07:18:43

标签: razor

我正在为网页编写剃刀语法。我的问题是我有一个包含员工电子邮件地址的表,我想在表单字段中单击任何名称后向他们发送电子邮件。

这是我到目前为止所尝试的内容:

// Initialize WebMail helper
        WebMail.SmtpServer = "smtp.office365.com";
        WebMail.SmtpPort = 25;
        WebMail.UserName = "";
        WebMail.Password = "";
        WebMail.From = "";
        WebMail.EnableSsl = true;




//i want to send a message to an email
WebMail.Send(to: Email,
subject: "Visitor Alert",
body: " From: <br/> " + "Name: " + full_name + "<br/> " + " Mobile Number: " 
+ phone_number + "<br/> " + " Address :" + address);

//this is html part
<div class="form-group">
@{


var data = "SELECT FullName,Email From Employee ORDER BY Email";
var DB = Database.Open("VisitorConnectionString").Query(data);


<label>Whom to See</label>
<select class="form-control">

<option>---Select Staff---</option>
//here was to populate the name of the employees from database                                                                       
@foreach (var item in DB)
{


<option name="Email" value="@item.FullName">@item.FUllName</option>



 }


</select>
        }

1 个答案:

答案 0 :(得分:0)

我已经弄明白了,写了一个sql语句来从数据库中获取电子邮件, 然后将它与下拉列表一起循环。 感谢。