< Back
Send-InlineMailMessage
Post
NAME Send-InlineMailMessage
SYNOPSIS
PowerShell version of the Send-MailMessage cmdlet with support for displaying attachments inline.
SYNTAX
Send-InlineMailMessage [-Attachments <String[]>] [-InlineAttachments <Hashtable>] [-Bcc <MailAddress[]>] [[-Body]
<String>] [-BodyAsHtml] [-Cc <MailAddress[]>] [-DeliveryNotificationOption {None | OnSuccess | OnFailure | Delay |
Never}] -From <MailAddress> [[-SmtpServer] <String>] [-Priority {Normal | Low | High}] [-Subject] <String> [-To]
<MailAddress[]> [-Credential <PSCredential>] [-UseSsl] [-Port <Int32>] [<CommonParameters>]
DESCRIPTION
PowerShell version of the Send-MailMessage cmdlet with support for displaying attachments inline. Also adds a
-Port parameter, which did not exist in the Send-MailMessage cmdlet until PowerShell 3.0.
PARAMETERS
-Attachments <String[]>
Required? false
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-InlineAttachments <Hashtable>
Hashtable of ContentID to FilePath mappings. The files referenced by the hashtables values will be attached
to the email, and may be displayed inline in the HTML body by using URIs of "cid:ContentID".
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Bcc <MailAddress[]>
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Body <String>
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-BodyAsHtml [<SwitchParameter>]
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Cc <MailAddress[]>
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DeliveryNotificationOption
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-From <MailAddress>
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SmtpServer <String>
Required? false
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Priority
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Subject <String>
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-To <MailAddress[]>
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Credential <PSCredential>
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-UseSsl [<SwitchParameter>]
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Port <Int32>
Required? false
Position? named
Default value 25
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
String.
The -Attachments parameter accepts pipeline input, as it does in the built-in Send-MailMessage cmdlet.
OUTPUTS
None. This command does not generate pipeline output.
NOTES
Refer to the Send-MailMessage cmdlet's
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>In this example, the two ContentIDs are "image1" and "image2". Those two attachments (test.jpg and
test2.png) can be displayed inline.
The rest of the parameters to this function are used the same way they would be used in PowerShell 3.0's
Send-MailMessage cmdlet (and in PowerShell 2.0's version as well, except for the -Port parameter.)
To keep the code readable, splatting is used to send the parameters to the function via a hashtable.
$images = @{
image1 = 'c:\\temp\\test.jpg'
image2 = 'C:\\temp\\test2.png'
}
$body = '<html>
<body>
<img src="cid:image1"><br>
<img src="cid:image2">
</body>
</html>'
$params = @{
InlineAttachments = $images
Attachments = 'C:\\temp\\attachment1.txt', 'C:\\temp\\attachment2.txt'
Body = $body
BodyAsHtml = $true
Subject = 'Test email'
From = 'username@gmail.com'
To = 'recipient@domain.com'
Cc = 'recipient2@domain.com', 'recipient3@domain.com'
SmtpServer = 'smtp.gmail.com'
Port = 587
Credential = (Get-Credential)
UseSsl = $true
}
Send-InlineMailMessage @params
RELATED LINKS
Send-MailMessage
SYNOPSIS
PowerShell version of the Send-MailMessage cmdlet with support for displaying attachments inline.
SYNTAX
Send-InlineMailMessage [-Attachments <String[]>] [-InlineAttachments <Hashtable>] [-Bcc <MailAddress[]>] [[-Body]
<String>] [-BodyAsHtml] [-Cc <MailAddress[]>] [-DeliveryNotificationOption {None | OnSuccess | OnFailure | Delay |
Never}] -From <MailAddress> [[-SmtpServer] <String>] [-Priority {Normal | Low | High}] [-Subject] <String> [-To]
<MailAddress[]> [-Credential <PSCredential>] [-UseSsl] [-Port <Int32>] [<CommonParameters>]
DESCRIPTION
PowerShell version of the Send-MailMessage cmdlet with support for displaying attachments inline. Also adds a
-Port parameter, which did not exist in the Send-MailMessage cmdlet until PowerShell 3.0.
PARAMETERS
-Attachments <String[]>
Required? false
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-InlineAttachments <Hashtable>
Hashtable of ContentID to FilePath mappings. The files referenced by the hashtables values will be attached
to the email, and may be displayed inline in the HTML body by using URIs of "cid:ContentID".
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Bcc <MailAddress[]>
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Body <String>
Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-BodyAsHtml [<SwitchParameter>]
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Cc <MailAddress[]>
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DeliveryNotificationOption
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-From <MailAddress>
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-SmtpServer <String>
Required? false
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Priority
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Subject <String>
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-To <MailAddress[]>
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Credential <PSCredential>
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-UseSsl [<SwitchParameter>]
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Port <Int32>
Required? false
Position? named
Default value 25
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
String.
The -Attachments parameter accepts pipeline input, as it does in the built-in Send-MailMessage cmdlet.
OUTPUTS
None. This command does not generate pipeline output.
NOTES
Refer to the Send-MailMessage cmdlet's
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>In this example, the two ContentIDs are "image1" and "image2". Those two attachments (test.jpg and
test2.png) can be displayed inline.
The rest of the parameters to this function are used the same way they would be used in PowerShell 3.0's
Send-MailMessage cmdlet (and in PowerShell 2.0's version as well, except for the -Port parameter.)
To keep the code readable, splatting is used to send the parameters to the function via a hashtable.
$images = @{
image1 = 'c:\\temp\\test.jpg'
image2 = 'C:\\temp\\test2.png'
}
$body = '<html>
<body>
<img src="cid:image1"><br>
<img src="cid:image2">
</body>
</html>'
$params = @{
InlineAttachments = $images
Attachments = 'C:\\temp\\attachment1.txt', 'C:\\temp\\attachment2.txt'
Body = $body
BodyAsHtml = $true
Subject = 'Test email'
From = 'username@gmail.com'
To = 'recipient@domain.com'
Cc = 'recipient2@domain.com', 'recipient3@domain.com'
SmtpServer = 'smtp.gmail.com'
Port = 587
Credential = (Get-Credential)
UseSsl = $true
}
Send-InlineMailMessage @params
RELATED LINKS
Send-MailMessage