首页 > 解决方案 > 剃须刀网页上的 SMTP

问题描述

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

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

// 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>
        }

标签: razor

解决方案


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


推荐阅读