简体   繁体   English

使用Powershell将HTML正文添加到电子邮件中

[英]Add HTML body to an email with Powershell

I'm using powershell to notify a high number of users about an expiration date of a document. 我正在使用Powershell通知大量用户有关文档的到期日期。

I have my script prepared 我准备好剧本

 $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 = I need to include HTML content, or MHT or bin as outlook message format. $ msg.body = 我需要包含HTML内容或MHT或bin作为Outlook消息格式。

 $smtp.Send($msg)

But the email body was preformatted using outlook, so it contains images, preformated text etc. Which would be the best way to include that kind of content in the message body?? 但是电子邮件正文是使用Outlook预先格式化的,因此它包含图像,预先格式化的文本等。这将是在邮件正文中包含此类内容的最佳方式?

Thank you! 谢谢!

如果将Body作为html字符串添加并添加以下行,则应该可以使用:

$msg.IsBodyHTML = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM