Display image in email body

Viewed 122

I am trying to display an image in powershell email body

tried below

$body = @"
Hi Team,

Please find the attached report 

Note: To view the Index page, please click on Enable editing option in excel

    <html>
        <body style="font-family:calibri"> 
            <img src='cid:enable_editing.png'>
        </body>
    </html>


Thank you

***This is an auto-generated email. Please do not respond***
"@

There are 2 excel attachment which goes with the email.

Please let me know how to display that

When I am sending the image as attachment and making -BodyAsHTML, I am loosing the email formatting

enter image description here

1 Answers

Naturally with -BodyAsHTML your text would need to be part of the HTML and naturally you'd need to use HTML linebreaks to well ... have linebreaks. Your whole body needs to be HTML.

So for example you'd have something like:

<html><body>
<p>Hi Team,</p>
<p>Please find the attached report. <br/> To view it to X.</p>
<img ... />
</body></html>

Beware that HTML formating is usually limited within mail clients. Not every tag and CSS format will work.

Related