【问题标题】:Add HTML body to an email with Powershell使用 Powershell 将 HTML 正文添加到电子邮件
【发布时间】:2014-04-24 06:09:02
【问题描述】:

我正在使用 powershell 通知大量用户文档的到期日期。

我已经准备好了剧本

 $smtpServer = "xxxxx.contoso.com"
 $msg = new-object Net.Mail.MailMessage
 $smtp = new-object Net.Mail.SmtpClient($smtpServer)
 $msg.From = New-Object Net.Mail.mailaddress "xxxx@contoso.es", "xxx yyy zzz"
 $msg.ReplyTo = "no-reply@contoso.es"
 $msg.To.Add("xxx@contoso.es")
 $msg.bcc.add($bcc)
 $msg.subject = "Expiration notification"

$msg.body = 我需要包含 HTML 内容,或 MHT 或 bin 作为 Outlook 消息格式。

 $smtp.Send($msg)

但是电子邮件正文是使用 Outlook 预先格式化的,因此它包含图像、预先格式化的文本等。在邮件正文中包含此类内容的最佳方式是什么??

谢谢!

【问题讨论】:

    标签: html email powershell outlook smtp


    【解决方案1】:

    如果您将正文添加为 html 字符串并添加该行,它应该可以工作:

    $msg.IsBodyHTML = true
    

    【讨论】:

    • 它不仅是一个 html 文件,而且是一个包含图像的文件夹......它是否应该工作@ben?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-25
    • 1970-01-01
    • 2011-04-29
    • 2015-07-05
    • 2010-12-20
    相关资源
    最近更新 更多