使用HttpPostedFileBase

时间:2018-04-25 06:17:49

标签: c# asp.net-mvc

我使用下面的代码附加文件

    public void SendMailMessage(string email, string subject, string body, string emailUrl, HttpPostedFileBase attachment)
    {

    MailMessage message = new MailMessage();

    message.Subject = subject;

    message.To.Add(email);

    message.Body = body;

    message.IsBodyHtml = true;

    if (attachment != null && attachment.FileName != null)
    {
        message.Attachments.Add(new Attachment(attachment.InputStream, attachment.FileName));
    }
    EmailerClass.SendMail(message);
}

但邮件中没有附件,我们如何使用HttpPostedFileBase发送附件?

0 个答案:

没有答案