CID#
CID is a special way to insert images or other media files directly into the body of an email so that they are displayed immediately, without the need to download them separately.
- In the email, images are inserted using the tag
<img src='cid:unique_ID'>. - The unique ID (Content-ID) links the image to this tag.
- These IDs and the images themselves are stored in the database.
- When displaying the email, the program searches for images by these IDs and shows them.
This structure works for web pages; however, Outlook may not display such images. This is especially relevant for Office 2019.
Exchange Connection Settings#
$exchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2016
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($exchangeVersion)
$service.Credentials = New-Object System.Net.NetworkCredential($ , $ )
$service.Url = "https:// / /Exchange.asmx"
Creating an Email#
$email = New-Object Microsoft.Exchange.WebServices.Data.EmailMessage($service)
$email.Subject = $subject
$email.Body = New-Object Microsoft.Exchange.WebServices.Data.MessageBody(
[Microsoft.Exchange.WebServices.Data.BodyType]::HTML,
"<html><body><p style = `"font-size: 15px; font-family: Calibri;`">${$header}<br>${$link}<br></p><img src='cid:MyImage'>$($ )</body></html>"
)
$emailAddresses = $Row.emails -split ';' | ForEach-Object { $_.Trim() }
foreach ($address in $emailAddresses) {
$email.ToRecipients.Add($address)
}
Adding an Attachment with ContentId#
$filePath = $
$attachment = $email.Attachments.AddFileAttachment($filePath)
$attachment.ContentId = "MyImage"
$attachment.IsInline = $true
Sending the Email#
$email.SendAndSaveCopy()
.png)