我正在尝试将一些填写在contactform中的信息发送到邮件,并将html文件作为正文文件。 我一直收到nullvalue的错误:
Dim mailMes As System.Net.Mail.MailMessage = _
mailDef.CreateMailMessage(toAdres, replacements, New System.Web.UI.Control())
当我在createmessage中插入html文件的字符串时,它似乎发送了一封邮件而不是html文件。我只看到字符串而不是替换内容。
我做错了什么?功能在模块(mvc应用程序)
中这是我的代码:
Imports System.Net.Mail
' ...
Dim mailDef As MailDefinition = New MailDefinition()
mailDef.BodyFileName = "~/Templates/ContactForm-EmailTemplate.htm"
mailDef.IsBodyHtml = True
mailDef.From = fromAdres
mailDef.Subject = subject
Dim mailMes As MailMessage = _
mailDef.CreateMailMessage(toAdres, replacements, New System.Web.UI.Control())
mailMes.Sender = New MailAddress(fromAdres, displayName)
Dim smtpClient As SmtpClient = New SmtpClient()
smtpClient.Send(mailMes)