Send-ModernMailMessage
SYNOPSIS
Sends an email message.
SYNTAX
GRAPH (Default)
Send-ModernMailMessage [[-Attachment] <String[]>] [[-Bcc] <String[]>] [[-Body] <String>] [-BodyAsHtml]
[[-Cc] <String[]>] [[-DeliveryNotificationOption] <String[]>] [[-From] <String>] [[-Priority] <String>]
[[-ReplyTo] <String[]>] [[-Subject] <String>] [-To] <String[]> [[-Credential] <PSCredential>]
[-SaveToSentItems] [-RequestReadReceipt] [-RequestDeliveryReceipt] [-DisableTelemetry] [-Modus <String>]
[-ClientId <String>] [-TenantId <String>] [-CertificateThumbprint <String>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
SMTP
Send-ModernMailMessage [[-Attachment] <String[]>] [[-Bcc] <String[]>] [[-Body] <String>] [-BodyAsHtml]
[[-Encoding] <Encoding>] [[-Cc] <String[]>] [[-DeliveryNotificationOption] <String[]>] [[-From] <String>]
[[-SmtpServer] <String>] [[-Priority] <String>] [[-ReplyTo] <String[]>] [[-Subject] <String>] [-To] <String[]>
[[-Credential] <PSCredential>] [-UseSsl] [-SslMethod <String>] [[-Port] <Int32>] [-DisableTelemetry]
[-Modus <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
TEAMS
Send-ModernMailMessage [[-Attachment] <String[]>] [[-Bcc] <String[]>] [[-Body] <String>] [-BodyAsHtml]
[[-Cc] <String[]>] [[-DeliveryNotificationOption] <String[]>] [-From] <String> [[-Priority] <String>]
[[-ReplyTo] <String[]>] [[-Subject] <String>] [-To] <String[]> [[-Credential] <PSCredential>]
[-DisableTelemetry] [-Modus <String>] [-ClientId <String>] [-TenantId <String>]
[-CertificateThumbprint <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
DESCRIPTION
The Send-ModernMailMessage cmdlet sends an email message from within PowerShell.
EXAMPLES
EXAMPLE 1
Send-ModernMailMessage -From "user01@fabrikam.com" -To "user02@fabrikam.com" -Subject "Test mail"
Send-ModernMailMessage -From "user01@fabrikam.com" -To "user02@fabrikam.com" -Subject "Test mail" -SmtpServer smtp.contoso.com -UseSsl -Port 587
Send-ModernMailMessage -From "user01@fabrikam.com" -To "user02@fabrikam.com" -Subject "Test mail" -ClientId [AppId] -CertificateThumbprint [Thumbprint] -TenantId [TenantId]
PARAMETERS
-Attachment
The path and file names of files to be attached to the email message.
Type: String[]
Parameter Sets: (All)
Aliases: Attachments
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Bcc
Email addresses that receive a copy of the mail but are not listed as recipients of the message. [Array] $Bcc,
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Body
The body (content) of the email message. [string[]] $Text,
Type: String
Parameter Sets: (All)
Aliases: Message
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-BodyAsHtml
Indicates that the value of the Body parameter contains HTML. [Alias("Body")] [string[]] $HTML,
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Encoding
The encoding used for the body and subject. Explicitly reference System.Text.Encoding
Type: Encoding
Parameter Sets: SMTP
Aliases:
Required: False
Position: 5
Default value: [System.Text.Encoding]::Default
Accept pipeline input: False
Accept wildcard characters: False
-Cc
Email addresses to which a carbon copy (CC) of the email message is sent. [Array] $Cc,
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-DeliveryNotificationOption
Delivery notifications (if accepted by the recipient) [System.Net.Mail.DeliveryNotificationOptions]$DeliveryNotificationOption, Explicitly reference System.Net.Mail Delivery notification options with validation
Type: String[]
Parameter Sets: (All)
Aliases: Dno
Required: False
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-From
The address from which the mail is sent. [object] $From,
Type: String
Parameter Sets: GRAPH, SMTP
Aliases: UserPrincipalName, UserId
Required: False
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Type: String
Parameter Sets: TEAMS
Aliases: UserPrincipalName, UserId
Required: True
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-SmtpServer
The name of the SMTP server that sends the email message (legacy).
Type: String
Parameter Sets: SMTP
Aliases: Server, Host
Required: False
Position: 9
Default value: Smtp.office365.com
Accept pipeline input: False
Accept wildcard characters: False
-Priority
The priority of the email message. [System.Net.Mail.MailPriority]$Priority, # Explicitly reference System.Net.Mail.MailPriority
Type: String
Parameter Sets: (All)
Aliases: Importance
Required: False
Position: 10
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-ReplyTo
Specifies additional email addresses (other than the From address) to use to reply to this message [string] $ReplyTo,
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 11
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Subject
The subject of the email message. [string] $Subject,
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 12
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-To
The addresses to which the mail is sent [Array] $To, [Parameter(Mandatory = $true)]
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 13
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Credential
A user account that has permission to perform this action (legacy).
Type: PSCredential
Parameter Sets: (All)
Aliases:
Required: False
Position: 14
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-UseSsl
Use the Secure Sockets Layer (SSL) protocol to establish a connection (legacy). Default: StartTls, On: Ssl, Off: N/A
Type: SwitchParameter
Parameter Sets: SMTP
Aliases:
Required: False
Position: 15
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-SslMethod
SecureSocketOptions (use with -UseSsl)
Type: String
Parameter Sets: SMTP
Aliases: SecureSocketOption, SslEncryption, Encryption
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Port
An alternate port on the SMTP server. Default: 587, Custom: 25, Ssl: 465
Type: Int32
Parameter Sets: SMTP
Aliases:
Required: False
Position: 16
Default value: 587
Accept pipeline input: False
Accept wildcard characters: False
-SaveToSentItems
Indicates whether to save the message in Sent Items.
Type: SwitchParameter
Parameter Sets: GRAPH
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-RequestReadReceipt
Indicates whether a read receipt is requested for the message. ToDevelop:IsReadReceiptRequested
Type: SwitchParameter
Parameter Sets: GRAPH
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-RequestDeliveryReceipt
Indicates whether a delivery receipt is requested for the message. ToDevelop: IsDeliveryReceiptRequested
Type: SwitchParameter
Parameter Sets: GRAPH
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-DisableTelemetry
Disable Telemetry If set, telemetry information will not be logged.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Modus
Modus defines the mode of operation for sending notifications. Default: None Fallback: Graph with Delegation (user-based interaction). Fallback: User-based delegation for Microsoft Graph (interactive). Recommended:
- 'GRAPH': App-only authentication (certificate-based) for Graph API.
- 'SMTP': SMTP-based email sending (e.g., OAuth2 authentication).
- 'TEAMS': Teams webhook notification (send notifications to a Teams channel).
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: GRAPH
Accept pipeline input: False
Accept wildcard characters: False
-ClientId
Specifies the application ID of the service principal that is used in application-based authentication.
Type: String
Parameter Sets: GRAPH, TEAMS
Aliases: ApplicationId, AppId
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-TenantId
Specifies the ID of a tenant. Organization
Type: String
Parameter Sets: GRAPH, TEAMS
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-CertificateThumbprint
Specifies the certificate thumbprint of a digital public key X.509 certificate of an application that has permission to perform this action.
Type: String
Parameter Sets: GRAPH, TEAMS
Aliases: Thumbprint
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction
Fill ProgressAction Description
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
None
OUTPUTS
System.Reflection.Assembly
NOTES
Use "Enable-MailMessageAlias" to enable the command "Send-MailMessage".
RELATED LINKS
https://exchangepermissions.alweys.ch/modernmailtools/Send-ModernMailMessage