< Back

Send-HtmlMailMessage

Sat Jan 18, 2020 8:16 pm

NAME Send-HtmlMailMessage



SYNOPSIS

Sends a nicely formatted HTML email.





SYNTAX

Send-HtmlMailMessage -From <String> -Subject <String> -To <String[]> -Body <String> [-BodyAlignment <String>]

[-BodyPreformatted <String>] [-Attachments <String[]>] [-Bcc <String[]>] [-Cc <String[]>] [-Credential

<PSCredential>] [-DeliveryNotificationOption <String>] [-Encoding <String>] [-Port <Int32>] [-SmtpServer <String>]

[-UseSsl] [-Priority <String>] [-Heading <String>] [-HeadingAlignment <String>] [-Footer <String>] [-LastLine

<String>] [<CommonParameters>]



Send-HtmlMailMessage -From <String> -Subject <String> -To <String[]> -Body <String> [-BodyAlignment <String>]

[-BodyPreformatted <String>] [-Attachments <String[]>] [-Bcc <String[]>] [-Cc <String[]>] [-Credential

<PSCredential>] [-DeliveryNotificationOption <String>] [-Encoding <String>] [-Port <Int32>] [-SmtpServer <String>]

[-UseSsl] [-Priority <String>] [-Heading <String>] [-HeadingAlignment <String>] [-Footer <String>] [-LastLine

<String>] -ButtonText <String> -ButtonLink <String> [-ButtonAlignment <String>] [<CommonParameters>]





DESCRIPTION

Sends a nicely formatted HTML email. This cmdlet is designed to work just like Send-MailMessage, with -Heading,

-Body, -BodyFormatted, and -Footer replacing the default -Body of Send-MailMessage.





PARAMETERS

-From <String>

Specifies the address from which the mail is sent. Enter a name (optional) and email address, such as Name

<someone@example.com>. This parameter is required.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Subject <String>

Specifies the subject of the email message. This parameter is required.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-To <String[]>

Specifies the addresses to which the mail is sent. Enter names (optional) and the email address, such as Name

<someone@example.com>. This parameter is required.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Body <String>

Specifies a string (with optional HTML formatting) to include in the body of the message. This parameter is

required.

Multiple paragraphs should have each paragraph wrapped as follows:

- <p>Paragraph 1</p><p>Paragraph 2</p>

If you need to include preformatted data, you should use the -BodyPreformatted attribute as well



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-BodyAlignment <String>

Specifies how the body should be aligned. The acceptable values for this parameter are:

- Left

- Center

- Right

Left is the default.



Required? false

Position? named

Default value Left

Accept pipeline input? false

Accept wildcard characters? false



-BodyPreformatted <String>

Specifies a string of preformmated text (code, cmdlet output, etc) to include below the body of the message.

This will be displayed either in a horizontally-scrolling box or, if Outlook (which can't support scrolling)

wrapped with line numbers.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Attachments <String[]>

Specifies the path and file names of files to be attached to the email message. You can use this parameter or

pipe the paths and file names to Send-HtmlMailMessage.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Bcc <String[]>

Specifies the email addresses that receive a copy of the mail but are not listed as recipients of the message.

Enter names (optional) and the email address, such as Name <someone@example.com>.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Cc <String[]>

Specifies the email addresses to which a carbon copy (CC) of the email message is sent. Enter names (optional)

and the email address, such as Name <someone@example.com>.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Credential <PSCredential>

Specifies a user account that has permission to perform this action. The default is the current user.

Type a user name, such as User01 or Domain01\\User01. Or, enter a PSCredential object, such as one from the

Get-Credential cmdlet.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-DeliveryNotificationOption <String>

Specifies the delivery notification options for the email message. You can specify multiple values. None is

the default value. The alias for this parameter is dno.

The delivery notifications are sent in an email message to the address specified in the value of the From

parameter. The acceptable values for this parameter are:

- None. No notification.

- OnSuccess. Notify if the delivery is successful.

- OnFailure. Notify if the delivery is unsuccessful.

- Delay. Notify if the delivery is delayed.

- Never. Never notify.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Encoding <String>

Specifies the encoding used for the body and subject. The acceptable values for this parameter are:

- ASCII

- UTF8

- UTF7

- UTF32

- Unicode

- BigEndianUnicode

- Default

- OEM

ASCII is the default.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Port <Int32>

Specifies an alternate port on the SMTP server. The default value is 25, which is the default SMTP port.



Required? false

Position? named

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-SmtpServer <String>

Specifies the name of the SMTP server that sends the email message.

The default value is the value of the $PSEmailServer preference variable. If the preference variable is not

set and this parameter is omitted, the command fails.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-UseSsl [<SwitchParameter>]

Indicates that the cmdlet uses the Secure Sockets Layer (SSL) protocol to establish a connection to the remote

computer to send mail. By default, SSL is not used.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Priority <String>

Specifies the priority of the email message. The acceptable values for this parameter are:

- Normal

- High

- Low

Normal is the default.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Heading <String>

Specifies a string (with optional HTML formatting) to include in the heading of the message.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-HeadingAlignment <String>

Specifies how the heading should be aligned. The acceptable values for this parameter are:

- Left

- Center

- Right

Center is the default.



Required? false

Position? named

Default value Center

Accept pipeline input? false

Accept wildcard characters? false



-Footer <String>

Specifies a string (with optional HTML formatting) to include in the footer of the message.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-LastLine <String>

Specifies a string (with optional HTML formatting) to include in the last line of the message.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ButtonText <String>

Specifies a string to use as label for an optional button.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ButtonLink <String>

Specifies a link to use as a target for an optional button.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ButtonAlignment <String>

Specifies how the button should be aligned. The acceptable values for this parameter are:

- Left

- Center

- Right

Center is the default.



Required? false

Position? named

Default value Center

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

No inputs





OUTPUTS

No outputs





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Send-HtmlMailMessage -From "server01@contoso.com" -To "admin@contoso.com"















RELATED LINKS

https://github.com/natescherer/PoshEmail