4

写真を埋め込んで(添付せずに)メールを送信する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 = "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’&gt;
              Voice and data hourly stats details<br />
             </p>
             <img src='cid:pict'/>"
    $msg.IsBodyHTML = $true
    $smtp.Send($msg)
    $att.Dispose()
    invoke-expression "DEL $file"
}

メールの写真はこんな感じ。圧縮写真

4

4 に答える 4

2

メール クライアントがコンテンツを特定の最大サイズに縮小しているようです。環境に入れてみてください<img src='cid:pict'/><div>

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

また、画像の実際のピクセル幅を取得する方法がある場合は、<img>それに応じてタグの CSS を設定してみてください。

于 2016-07-25T13:57:54.257 に答える
2

追加してみる

$att.ContentDisposition.Inline = $true

スクリプトと Outlook の間で一貫性がないだけで、内部でデフォルトの動作が発生していると思われます。

詳細はこちら

于 2013-08-28T19:09:25.767 に答える
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()

上でコメントしようとしたので、これに答えているだけですが、評判スコアが低すぎてそれを行うことができないと思います。これが回避策を見つけるのに役立つことを願っています。ハッピーコーディング。:)

于 2016-07-26T11:15:10.527 に答える
-2

HTML コード:スラッシュを削除するだけですか<img src='cid:pict'/>?<img src='cid:pict'>

追加: このリンクは、電子メールに写真を埋め込むことについて話すのに役立つかもしれません。メール署名の base64 でエンコードされた画像。base64 コードの生成を試して、メール本文の HTML に入れることができます。

于 2013-07-08T23:03:01.820 に答える