powershell电子邮件压缩图片长度

powershell电子邮件压缩图片长度

本文介绍了嵌入式html powershell电子邮件压缩图片长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PowerShell脚本,嵌入(不附加)图片并发送电子邮件。现在的图片已经增加到1500x5000像素,现在我看到图片被压缩了,它扭曲了图片。如何,当我通过outlook手动插入图片并发送电子邮件,它看起来不错。



如果我保存图片,然后通过油漆或其他东西打开,图片打开。它只是在电子邮件中看起来压缩。任何人都知道那里可能发生什么?

  {
$ Application =C:\Autobatch\Spotfire .Dxp.Automation.ClientJobSender.exe
$ Arguments =http://s.net:8070/spotfireautomation/JobExecutor.asmx C:\Autobatch\HourlyStats.xml
$ CommandLine = {0} {1}-f $ Application,$ Arguments
invoke-expression $ CommandLine
$ file =C:\Autobatch\HourlyStats.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 =语音和数据每小时统计
$ msg.Body =< p style ='font-family:Calibri,sans-serif'>
语音和数据小时数据细节< br />
< / p>
< img src ='cid:pict'/>
$ msg.IsBodyHTML = $ true
$ smtp.Send($ msg)
$ att.Dispose )
invoke-expressionDEL $ file
}

这里是什么图片看起来像电子邮件。

解决方案

似乎你的电子邮件客户端将内容缩小到一定的最大大小,尝试放入< img src ='cid:pict'/> < div> 环境:

  div style =overflow:scroll> 
< img src ='cid:pict'/>
< / div>

另外,如果您有任何方法来检索图像的实际像素宽度,可以尝试设置< img> ; 标签相应。


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:\Autobatch\Spotfire.Dxp.Automation.ClientJobSender.exe"
    $Arguments  = "http://s.net:8070/spotfireautomation/JobExecutor.asmx C:\Autobatch\HourlyStats.xml"
    $CommandLine = "{0} {1}" -f $Application,$Arguments
    invoke-expression $CommandLine
    $file = "C:\Autobatch\HourlyStats.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.

解决方案

It seems like your email client shrinks content to a certain maximum size. Try putting <img src='cid:pict'/> in a <div> environment:

<div style="overflow: scroll">
  <img src='cid:pict'/>
</div>

Also, if you have any way to retrieve the actual pixel width of the image, you can try to set the CSS of the <img> tag accordingly.

这篇关于嵌入式html powershell电子邮件压缩图片长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 20:03