HTML IMG tag not showing images from computer

I have a script that emails users when their AD password in 3 days or less. Everything works.
But now, I want to put some pictures in the e-mail body using HTML.

When I use the tag, I can only see the images on my email when they’re from the internet. But when I use the image from the folder (same folder as in PowerShell), it just displays an X.

What am I doing wrong? I tried .\image.png, …\image.png, \image.png, and with full path. Nothing works.

$smtp_server = ''
$from_email = ''
$users = get-aduser -filter * -properties *
$MaxPasswordAge = 60

$ErrorActionPreference = 'silentlycontinue'

foreach ($user in $users) {
    $user_email = ($user.SamAccountName)+''
    $user_name = $
    $user_last_pw_set = $user.PasswordLastSet
    $days_elapsed = (New-TimeSpan -Start $user_last_pw_set -End $today_date).Days
    $days_remaining = 60 - $days_elapsed  
    $today_date = get-Date  

    if ($days_remaining -le 3 -and $days_remaining -gt 0) {
        $email_subject = $user_name + ' Windows Password expiring soon!'

        $email_body = "<font size='3'>Hello <b>$user_name</b>, <br><br>"
        $email_body+= "Your <i><u>Windows and Outlook password</i></u> will expire in <font color = 'red'><b>$days_remaining</b></font> days!<br><br>" 
        $email_body+= "<u>Password requirements:</u>"
        $email_body+= "<ul>"
        $email_body+= "<li>Minimum 8 characters in length</li>"
        $email_body+= "<li>Uppercase characters A-Z (Latin alphabet)</li>"
        $email_body+= "<li>Lowercase characters a-z (Latin alphabet)</li>"
        $email_body+= "<li>Digits 0-9</li>"
        $email_body+= "<li>Special characters (!, $, #, %, etc.)</li>"
        $email_body+= "<li>Don't user your username in your password</li>"
        $email_body+= "</ul>"
        $email_body+= "You can change password by pressing <b>CTRL + ALT + DEL</b> on your keyboard.<br><br>"
        $email_body+= "<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAT4AAACeCAMAAACcjZZYAAAAulBMVEVFwroAAABHyMDLy8spZWIUU1CjoaFGxb3///8/rqcrbWnn5+cEBAQMIB82mpNaWlr29vYkb2qAfHyvr68tLS3Y2NhfX18dHR3w8PBoaGi3t7fHx8c3lY+pqanOzs4ZGRlzc3M6Ojrf39+VlZUmJiZSUlJAQEAI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ZpCZ2RzlX180zLE5L/lQeO1TU659ehDCY51Ohw8e6foyr32RPtNwuuPpuOtQrvXdRdnNTD3SR0J9hZSRN6yArjsoDxwtS18hfeSN9PEBw+07jtMY51sfaZ3gsaxFnddM11ei1WF9/KfFZmG5DSMYedup+sTzvrU+p09ll/9tt3PdeXU+cXGMeYe3PGLleaSvI9KnLp+rsRVcsvU1rHAA6RYDfZYdr4M9fa/Pn0J9mueNLV6VQ7NhjJkR6MvztHnmapo750/GxfGTE7RE4bQ5uP7F4sT0jfgEshcWs9d84HO2VnNn3iy35uUBPJczDaYDT27fatODO8yxvk1qm9MW8RXmvr5kHPGWQcaaN8GOvm08fftKjte8WVx2wyrr22Lo2wP6zqYvC+jbA/okgL69OND3B+rDEaEE0Ad9onS9FH0vmePtNgw5Z9Jn18WHrS/DEUe6dXJssb6SbBSuTxMejyyo0q042Na5+tBRKMif6R6amvgw8SL785tit1lDrO9TOh1qsPbV9amLcEWeuUIKtkBTil1QJtE2czYzm7V9cZyVXD5EHjP/nlz9zg7Zbmf0mf22FNe2Ink3UN1k3ZQT8bJn61sdxqZ0dXu8241mTreYQddmrN97TwnDu53hZsXpWiZjLqUNmLwZT92sdIp9xsxybJv6eqiL23+8ciaDJj2nZqvc08+6RJyvlJuTwnwm9DXNjjP+SWk3iV0OVZnc1G7SKdVuMm9iVNWlnxEmYJlyS1uIsqjdfH+nxviufZeWWfdmXgy5O3qzsz1XHKkwuWh6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC4Mv8C5x5+X4px8KUAAAAASUVORK5CYII=' width='318' height='158'"
        $email_body+= "<img src='' width='318' height='158'<br><br>"
        $email_body+= "Once you change your password, if you have company email on your smart phone, "
        $email_body+= "please enter your new password on there to receive emails again.<br><br>"
        $email_body+= "Thank you,<br><br>"
        $email_body+= "<i>IT Department</i></font>"

        Write-host 'USER:' , $user_name, 
        'PW_SET_ON:', $user_last_pw_set, 
        'DAYS_ELAPSED:', $days_elapsed, 
        'DAYS-REMAINING:', $days_remaining 

        $log = '[User] ' + $user_name + ' [Days remaining] '+ $days_remaining + ' [Email sent] ' + $today_date
        $log | Out-File -FilePath 'C:\Users\t.antonyadmin\Desktop\Expiring-Email-Alerts\log.txt' -Append

        Send-MailMessage -From $from_email -to $user_email -Subject $email_subject -Body $email_body -SmtpServer $smtp_server -BodyAsHtml

The image needs to be available over the network or internet. It’s not injecting the image. So give a valid network or web path to the image.

Just to be clear, for the image to show up, it needs to be network (UNC) path or web path (this works).
So something like C:\image.png won’t work?

Is there a way to embed the images on the html? Because now if I check the email from my iPhone, I can’t see it because I’m not on VPN / not on company network.

I can only see if I’m in the company network, when I’m at work.

This is not Powershell specific… but HTML 101.
If you wish to use images in email, you will need to store them somewhere which is generally accessible.

If your company has a web-site you may be able to get permission from the webmaster to store the images in a separate folder there.
Then you would link them in the mailbody with the full path such as “

Sorry, yes this is a HTML question. I had the images originally from a website, but I was thinking may be I could ‘embed’ them in the HTML code since the images are now not from internet.

HTML is pure text, every image, video or sound-file displayed on a web-page is external to the HTML itself. With the possible exception of graphics created with CSS and similar tech.
You can attach files to an e-mail, but I’m pretty sure there’s no real way of using attachments as components directly in the HTML-body of a mail.

Apparently you can get it to work:
Embedding attached images in HTML emails (StackOverflow)

It seems to require quite a bit of tweaking, so I suspect you’d have an easier time of just linking external images.

ok that’s what I thought, but just wanted to check. I’m not sure if I’m mixing something up, but I thought there was a way to ‘code’ the images into an html so its not using the tag.

Everything (almost) is possible… Is it realistic or worth it is another question.
Here’s a guide where you basically embed images directly into HTML by converting them to text via built-in Windows/Mac/Linux commands:
How to Embed an Image to Get a Self-Contained Web Page

That looks familiar, I’ll check it thanks