Project

PSWriteHTML

Generate HTML reports, dashboards, and emails from PowerShell without writing HTML, CSS, or JavaScript.

Stars 1,023
Forks 115
Open issues 54
PowerShell Gallery downloads 7,576,901
Release v1.45.0
Language: PowerShell Updated: 2026-11-03
Command

Email

Module
PSWriteHTML

Sends an email with specified parameters.

Syntax

Email
[-AttachSelf]
[-AttachSelfName <String>]
[-BCC <String[]>]
[-CC <String[]>]
[-DeliveryNotifications <OnSuccess|OnFailure|Delay|Never>]
[[-Email] <ScriptBlock>]
[-Encoding <String>]
[-FilePath <String>]
[-From <String>]
[-Online]
[-OutputHTML]
[-Password <String>]
[-PasswordAsSecure]
[-PasswordFromFile]
[-Port <Int32>]
[-Priority <Low|Normal|High>]
[-ReplyTo <String>]
[-Server <String>]
[-SSL]
[-Subject <String>]
[-Suppress <Boolean>]
[-To <String[]>]
[-Username <String>]
[<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

This function sends an email with the provided parameters including recipients, subject, content, and server settings.

Examples

Example 1

Email -FilePath 'C:\Path'

Parameters

-AttachSelf SwitchParameter optionalaliases: SelfAttach
Switch parameter to attach the email to itself.
-AttachSelfName String optional
Specifies the name of the attached email.
-BCC String[] optional
Specifies the email addresses of the blind carbon copy recipients.
-CC String[] optional
Specifies the email addresses of the carbon copy recipients.
-DeliveryNotifications Object optional
Specifies the type of delivery notifications. Valid values are 'None', 'OnSuccess', 'OnFailure', 'Delay', or 'Never'. Default is 'None'.
Possible values: OnSuccess, OnFailure, Delay, Never
-Email ScriptBlock optionalposition: 0
Specifies the ScriptBlock containing the email content and additional parameters.
-Encoding String optional
[Obsolete] Deprecated parameter. Encoding is set to UTF8 to prevent errors.
-FilePath String optional
Specifies the file path for attachments.
-From String optional
Specifies the email address of the sender.
-Online SwitchParameter optional
Switch parameter to send the email online without saving it.
-OutputHTML SwitchParameter optional
Switch parameter to output the email content as HTML.
-Password String optional
Specifies the password for authentication with the SMTP server.
-PasswordAsSecure SwitchParameter optional
Switch parameter to treat the password as a secure string.
-PasswordFromFile SwitchParameter optional
Switch parameter to indicate that the password is read from a file.
-Port Int32 optional
Specifies the port number for the SMTP server. Default is 587.
-Priority String optional
Specifies the priority of the email. Valid values are 'Low', 'Normal', or 'High'. Default is 'Normal'.
Possible values: Low, Normal, High
-ReplyTo String optional
Specifies the email address to set as the reply-to address.
-Server String optional
Specifies the SMTP server for sending the email.
-SSL SwitchParameter optional
Switch parameter to enable SSL for the SMTP connection.
-Subject String optional
Specifies the subject of the email.
-Suppress Boolean optionalaliases: Supress
Switch parameter to suppress sending the email.
-To String[] optional
Specifies the email addresses of the primary recipients.
-Username String optional
Specifies the username for authentication with the SMTP server.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.