我有一个powershell脚本嵌入(不附加)图片并发送电子邮件。图片现在增加到1500x5000像素,现在我看到图片lenth被压缩并且扭曲了图片。然而,当我通过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 = "d.k@s.com"
$msg.To.Add("r.p@p.com")
$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"
}
这是电子邮件中图片的样子。
答案 0 :(得分:2)
答案 1 :(得分:2)
您的电子邮件客户端似乎会将内容缩小到某个最大尺寸。尝试将<img src='cid:pict'/>
置于<div>
环境中:
<div style="overflow: scroll">
<img src='cid:pict'/>
</div>
此外,如果您有任何方法可以检索图像的实际像素宽度,则可以尝试相应地设置<img>
标记的CSS。
答案 2 :(得分:0)
通过询问这可能听起来像一个菜鸟,但只是出于好奇心,如果您有手动方式通过Outlook发送电子邮件,为什么不制作一个脚本来发送带有所需屏幕截图的自动电子邮件?
IDK,如果这可能对您有所帮助,但我已经将这个脚本长时间用于我的日常报告目的。嗯,这符合法案。在这里分享,以获取您对它的看法。
#In this segment, I navigate IE to my specific destination, screen which I want to capture.
$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $true;
$Website = $ie.navigate('https://put.your.URL.here')
while($Website.Busy){Start-Sleep -Seconds 5}
#In this class, script captures the screen, once, all the data loading is over.
$file = "C:\Users\Desktop\$(Get-Date -Format dd-MM-yyyy-hhmm).bmp"
#P.S. I made it to save that screenshot with current date and time format. Also, default screenshot will be captured in .BMP format.
Add-Type -AssemblyName System.Windows.Forms
Add-type -AssemblyName System.Drawing
$Screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
$width = $Screen.width
$Height = $Screen.Height
$Left = $Screen.Left
$Right = $Screen.Right
$Top = $Screen.Top
$Bottom = $Screen.Bottom
$bitmap = New-Object System.Drawing.Bitmap $width, $Height
$Graphics = [System.Drawing.Graphics]::FromImage($bitmap)
$Graphics.CopyFromScreen($Left, $Top, 0, 0, $bitmap.Size)
$bitmap.Save($File)
Write-Output "Screenshot saved to:"
Write-Output $File
sleep -Seconds 5
#Sending an Email
$Outlook = New-Object -ComObject Outlook.Application
$mail = $Outlook.CreateItem(0)
$mail.To = "your.designated@emailid.com"
$mail.Subject = "Outstanding data as on $(Get-Date -Format dd-MM-yyyy)"
$mail.Body = "PFA screenshot, of all outstanding formation as on $(Get-Date -Format dd-MM-yyyy-hhmm)"
$mail.Attachments.Add($file)
$mail.Send()
我正在回答这个问题,因为,我上面尝试过评论,但我想,我的声望得分太低了。 希望这可能有助于您找到解决方法。 快乐的编码。 :)
答案 3 :(得分:-2)
HTML代码:<img src='cid:pict'/>
应该是<img src='cid:pict'>
- 只是删除正斜杠?
补充:此链接可能有助于谈论在电子邮件中嵌入pic。 base64 encoded images in email signatures。您可以尝试生成base64代码并将其放在电子邮件正文HTML中。