Embedded Html Powershell Email Compressing Pic Length
Solution 1:
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
Solution 2:
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.
Solution 3:
By asking this I may sound like a noob, but Just out of Curiosity, if you have a manual way to send an email via Outlook, why not to make a script to send an automated email with desired screenshot?
IDK, if this might help you or not, but I had made this script long back, for my daily reporting purposes. Well, it fits the bill. Sharing it here, for your views on it.
#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()
I am just answering this, since, I tried commenting above, but I guess, my reputation score is way too less to do that. Hope this might be helpful for you to find a workaround. Happy coding. :)
Solution 4:
HTML code: is <img src='cid:pict'/>
supposed to be <img src='cid:pict'>
-just remove the forward slash?
Added: This link might help talking about embedding pic in email. base64 encoded images in email signatures. You can try generation base64 code and put it in email body HTML.
Post a Comment for "Embedded Html Powershell Email Compressing Pic Length"