Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
623 views
in Technique[技术] by (71.8m points)

embedded html powershell email compressing pic length

I have a powershell script that embedds (not attaches) a picture and sends an email. The picture has increased now to 1500x5000 pixels and now I'm seeing that the pictures lenth gets compressed and it distorts the picture. How ever, when I manually insert the picture via outlook and send an email, it looks fine.

If i save the picture and then open it via paint or something, the picture opens fine. It just looks compressed in the email. Anyone know what may be going on there?

{
    $Application = "C:AutobatchSpotfire.Dxp.Automation.ClientJobSender.exe"
    $Arguments  = "http://s.net:8070/spotfireautomation/JobExecutor.asmx C:AutobatchHourlyStats.xml"
    $CommandLine = "{0} {1}" -f $Application,$Arguments
    invoke-expression $CommandLine
    $file = "C:AutobatchHourlyStats.png"
    $smtpServer = "smtp.staom.sec.s.net"
    $att = new-object Net.Mail.Attachment($file)
    $att.ContentType.MediaType = “image/png”
    $att.ContentId = “pict”
    $att.TransferEncoding = [System.Net.Mime.TransferEncoding]::Base64
    $msg = new-object Net.Mail.MailMessage
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)
    $msg.Attachments.Add($att)
    $msg.From = "[email protected]"
    $msg.To.Add("[email protected]")
    $msg.Subject = "Voice and Data Hourly Stats"
    $msg.Body = "<p style=’font-family: Calibri, sans-serif’>
              Voice and data hourly stats details<br />
             </p>
             <img src='cid:pict'/>"
    $msg.IsBodyHTML = $true
    $smtp.Send($msg)
    $att.Dispose()
    invoke-expression "DEL $file"
}

here is what the picture looks like in the email.compressed pic

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try adding

$att.ContentDisposition.Inline = $true

I suspect some default behavior is happening under the covers and it's just not consistent between the script and Outlook.

More info here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...