尝试运行C#代码执行stmpt并将emal发送给用户

时间:2019-06-30 13:43:37

标签: .net model-view-controller

在过程结束时,根据需要将数据库中的内容发送并发送到电子邮件中

public class sendemail
{
    public static void Send(string to, string subject,
                            string body, string from,
                            string cc,
                            IEnumerable<string> filesToAttach,
                            bool isBodyHtml,
                            IEnumerable<string> additionalHeaders,
                            string bcc, string contentEncoding, c.html


<h2>sendemail</h2>
@{
    ViewBag.Title = "sendemail";
    Layout = "~/_SiteLayout.cshtml";

    var customerName = Request["customerName"];
    var customerEmail = Request["customerEmail"];
    var customerRequest = Request["customerRequest"];
    var subjectLine = Request["subjectLine"];
    var message = Request["message"];
    var fileAttachment = Request["fileAttachment"];
    var with = "with";
    var errorMessage = "";

    // use a try catch block and send the email
    try {
        // Initialize WebMail helper
        WebMail.SmtpServer = "your-smtp-server";
        WebMail.SmtpPort = 25;
        WebMail.UserName = "your-username";
        WebMail.Password = "password";
        WebMail.From = "your-email-address";
        WebMail.EnableSsl = true;

        // Create array containing file name
        var filesList = new string [] { fileAttachment };

        // Attach file and send email
        // if there is no link to file then send email
        // without any attachment
        if(fileAttachment == null || fileAttachment.IsEmpty()) {
            WebMail.Send(to: customerEmail,

错误:

  

严重性代码描述项目文件行抑制状态   错误CS0501'sendemail.Send(字符串,字符串,字符串,字符串,IEnumerable,布尔,IEnumerable,字符串,字符串,字符串,字符串,字符串)'必须声明一个主体,因为它没有标记为abstract,extern或Partial Bharat547 C:\ Users \ bharatsharma \ source \ repos \ Bharat547 \ Bharat547 \ Models \ sendemail.cs 11有效

0 个答案:

没有答案