I\'ve been toying with this for days with no luck. Essentially I\'m trying to build a simple library to render SSRS reports using Powershell. I\'m using Powershell in an a
Had the same issue, furthermore wanted to send the generated MHT file as an email body: The following was found to work The old CDO.Message is the only thing I found that allows sending a MHTML file as an email body. Below is a (working) translation of a VB program Old but simple ;-)!
################## Send MHTML email ##############################
# use antiquated CDO to send mhtml as email body
$smtpServer = "my-mail-server"
$smtpSubject = "MHT file sent as body of email"
$smtpTo = "you@work.com"
$smtpFrom = "me@home.org"
$MHTMLfile = "my-MHT-File.mht
# e.g. from an SSRS.Render
$AdoDbStream = New-Object -ComObject ADODB.Stream
$AdoDbStream.Charset = "ascii"
$AdoDbStream.Open()
$AdoDbStream.LoadFromFile($MHTMLfile)
$CdoMessage = New-Object -ComObject CDO.Message
$CdoMessage.DataSource.OpenObject($AdoDbStream,"_Stream")
$SendUsingPort = 2
$smtpPort = 25
$cfg = "http://schemas.microsoft.com/cdo/configuration/"
$CdoMessage.Configuration.Fields.Item($cfg + "sendusing") = $SendUsingPort
$CdoMessage.Configuration.Fields.Item($cfg + "smtpserver") = $SmtpServer
$CdoMessage.Configuration.Fields.Item($cfg + "smtpserverport") = $smtpPort
$CdoMessage.To = $smtpTo
$CdoMessage.From = $smtpFrom
$CdoMessage.Subject = $smtpSubject
$CdoMessage.MimeFormatted = $true
$CdoMessage.Configuration.Fields.Update()
WRITE-HOST "Sending email"
$CdoMessage.Send()