Send the message specified in the request body using either JSON or MIME format.
When using JSON format, you can include a file attachment in the same sendMail action call.
When using MIME format: This method saves the message in the Sent Items folder.
Alternatively, create a draft message to send later.
To learn more about the steps involved in the backend before a mail is delivered to recipients, see here.
Send the message specified in the request body using either JSON or MIME format.
When using JSON format, you can include a file attachment in the same sendMail action call.
When using MIME format: This method saves the message in the Sent Items folder.
Alternatively, create a draft message to send later.
To learn more about the steps involved in the backend before a mail is delivered to recipients, see here.
Permissions
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Mail.Send,
Delegated (personal Microsoft account)
Mail.Send,
Application
Mail.Send,
Examples
Example 1: Code snippet
Import-Module Microsoft.Graph.Users.Actions
$params = @{
message = @{
subject = "Meet for lunch?"
body = @{
contentType = "Text"
content = "The new cafeteria is open."
}
toRecipients = @(
@{
emailAddress = @{
address = "frannis@contoso.com"
}
}
)
ccRecipients = @(
@{
emailAddress = @{
address = "danas@contoso.com"
}
}
)
}
saveToSentItems = "false"
}
# A UPN can also be used as -UserId.
Send-MgUserMail -UserId $userId -BodyParameter $params
This example shows how to use the Send-MgUserMail Cmdlet.
Example 2: Code snippet
Import-Module Microsoft.Graph.Users.Actions
$params = @{
message = @{
subject = "9/9/2018: concert"
body = @{
contentType = "HTML"
content = "The group represents Nevada."
}
toRecipients = @(
@{
emailAddress = @{
address = "AlexW@contoso.com"
}
}
)
internetMessageHeaders = @(
@{
name = "x-custom-header-group-name"
value = "Nevada"
}
@{
name = "x-custom-header-group-id"
value = "NV001"
}
)
}
}
# A UPN can also be used as -UserId.
Send-MgUserMail -UserId $userId -BodyParameter $params
This example shows how to use the Send-MgUserMail Cmdlet.
Example 3: Code snippet
Import-Module Microsoft.Graph.Users.Actions
$params = @{
message = @{
subject = "Meet for lunch?"
body = @{
contentType = "Text"
content = "The new cafeteria is open."
}
toRecipients = @(
@{
emailAddress = @{
address = "meganb@contoso.com"
}
}
)
attachments = @(
@{
"@odata.type" = "#microsoft.graph.fileAttachment"
name = "attachment.txt"
contentType = "text/plain"
contentBytes = "SGVsbG8gV29ybGQh"
}
)
}
}
# A UPN can also be used as -UserId.
Send-MgUserMail -UserId $userId -BodyParameter $params
This example shows how to use the Send-MgUserMail Cmdlet.
Parameters
-AdditionalProperties
Additional Parameters
Parameter properties
Type:
Hashtable
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
SendExpanded
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
SendViaIdentityExpanded
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-BodyParameter
To construct, see NOTES section for BODYPARAMETER properties and create a hash table.
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
cf
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Headers
Optional headers that will be added to the request.
Parameter properties
Type:
IDictionary
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
True
Value from pipeline by property name:
False
Value from remaining arguments:
False
-InputObject
Identity Parameter
To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
Parameter properties
Type:
IUsersActionsIdentity
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
SendViaIdentityExpanded
Position:
Named
Mandatory:
True
Value from pipeline:
True
Value from pipeline by property name:
False
Value from remaining arguments:
False
SendViaIdentity
Position:
Named
Mandatory:
True
Value from pipeline:
True
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Message
message
To construct, see NOTES section for MESSAGE properties and create a hash table.
Parameter properties
Type:
IMicrosoftGraphMessage
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
SendExpanded
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
SendViaIdentityExpanded
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-PassThru
Returns true when the command succeeds
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ResponseHeadersVariable
Optional Response Headers Variable.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
RHV
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-SaveToSentItems
Send the message specified in the request body using either JSON or MIME format.
When using JSON format, you can include a file attachment in the same sendMail action call.
When using MIME format: This method saves the message in the Sent Items folder.
Alternatively, create a draft message to send later.
To learn more about the steps involved in the backend before a mail is delivered to recipients, see here.
Permissions
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Mail.Send,
Delegated (personal Microsoft account)
Mail.Send,
Application
Mail.Send,
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Parameter sets
SendExpanded
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
SendViaIdentityExpanded
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-UserId
The unique identifier of user
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
SendExpanded
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
Send
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
wi
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.
To create the parameters described below, construct a hash table containing the appropriate properties.
For information on hash tables, run Get-Help about_Hash_Tables.
[(Any) <Object>]: This indicates any property can be added to this object.
[Message <IMicrosoftGraphMessage>]: message
[(Any) <Object>]: This indicates any property can be added to this object.
[Categories <String- []>]: The categories associated with the item
[ChangeKey <String>]: Identifies the version of the item.
Every time the item is changed, changeKey changes as well.
This allows Exchange to apply changes to the correct version of the object.
Read-only.
[CreatedDateTime <DateTime?>]: The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z
[LastModifiedDateTime <DateTime?>]: The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z
[Id <String>]: The unique identifier for an entity.
Read-only.
[Attachments <IMicrosoftGraphAttachment- []>]: The fileAttachment and itemAttachment attachments for the message.
[Id <String>]: The unique identifier for an entity.
Read-only.
[ContentType <String>]: The MIME type.
[IsInline <Boolean?>]: true if the attachment is an inline attachment; otherwise, false.
[LastModifiedDateTime <DateTime?>]: The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z
[Name <String>]: The attachment's file name.
[Size <Int32?>]: The length of the attachment in bytes.
[BccRecipients <IMicrosoftGraphRecipient- []>]: The Bcc: recipients for the message.
[HasAttachments <Boolean?>]: Indicates whether the message has attachments.
This property doesn't include inline attachments, so if a message contains only inline attachments, this property is false.
To verify the existence of inline attachments, parse the body property to look for a src attribute, such as .
[InternetMessageHeaders <IMicrosoftGraphInternetMessageHeader- []>]: A collection of message headers defined by RFC5322.
The set includes message headers indicating the network path taken by a message from the sender to the recipient.
It can also contain custom message headers that hold app data for the message.
Returned only on applying a $select query option.
Read-only.
[Name <String>]: Represents the key in a key-value pair.
[Value <String>]: The value in a key-value pair.
[InternetMessageId <String>]: The message ID in the format specified by RFC2822.
[IsDeliveryReceiptRequested <Boolean?>]: Indicates whether a read receipt is requested for the message.
[IsDraft <Boolean?>]: Indicates whether the message is a draft.
A message is a draft if it hasn't been sent yet.
[IsRead <Boolean?>]: Indicates whether the message has been read.
[IsReadReceiptRequested <Boolean?>]: Indicates whether a read receipt is requested for the message.
[MultiValueExtendedProperties <IMicrosoftGraphMultiValueLegacyExtendedProperty- []>]: The collection of multi-value extended properties defined for the message.
Nullable.
[Id <String>]: The unique identifier for an entity.
Read-only.
[Value <String- []>]: A collection of property values.
[ParentFolderId <String>]: The unique identifier for the message's parent mailFolder.
[ReceivedDateTime <DateTime?>]: The date and time the message was received.
The date and time information uses ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z.
[ReplyTo <IMicrosoftGraphRecipient- []>]: The email addresses to use when replying.
[Sender <IMicrosoftGraphRecipient>]: recipient
[SentDateTime <DateTime?>]: The date and time the message was sent.
The date and time information uses ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z.
[SingleValueExtendedProperties <IMicrosoftGraphSingleValueLegacyExtendedProperty- []>]: The collection of single-value extended properties defined for the message.
Nullable.
[Id <String>]: The unique identifier for an entity.
Read-only.
[Value <String>]: A property value.
[Subject <String>]: The subject of the message.
[ToRecipients <IMicrosoftGraphRecipient- []>]: The To: recipients for the message.
[UniqueBody <IMicrosoftGraphItemBody>]: itemBody
[WebLink <String>]: The URL to open the message in Outlook on the web.You can append an ispopout argument to the end of the URL to change how the message is displayed.
If ispopout is not present or if it is set to 1, then the message is shown in a popout window.
If ispopout is set to 0, the browser shows the message in the Outlook on the web review pane.The message opens in the browser if you are signed in to your mailbox via Outlook on the web.
You are prompted to sign in if you are not already signed in with the browser.This URL cannot be accessed from within an iFrame.
[(Any) <Object>]: This indicates any property can be added to this object.
[Categories <String- []>]: The categories associated with the item
[ChangeKey <String>]: Identifies the version of the item.
Every time the item is changed, changeKey changes as well.
This allows Exchange to apply changes to the correct version of the object.
Read-only.
[CreatedDateTime <DateTime?>]: The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z
[LastModifiedDateTime <DateTime?>]: The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z
[Id <String>]: The unique identifier for an entity.
Read-only.
[Attachments <IMicrosoftGraphAttachment- []>]: The fileAttachment and itemAttachment attachments for the message.
[Id <String>]: The unique identifier for an entity.
Read-only.
[ContentType <String>]: The MIME type.
[IsInline <Boolean?>]: true if the attachment is an inline attachment; otherwise, false.
[LastModifiedDateTime <DateTime?>]: The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z
[Name <String>]: The attachment's file name.
[Size <Int32?>]: The length of the attachment in bytes.
[BccRecipients <IMicrosoftGraphRecipient- []>]: The Bcc: recipients for the message.
[HasAttachments <Boolean?>]: Indicates whether the message has attachments.
This property doesn't include inline attachments, so if a message contains only inline attachments, this property is false.
To verify the existence of inline attachments, parse the body property to look for a src attribute, such as .
[InternetMessageHeaders <IMicrosoftGraphInternetMessageHeader- []>]: A collection of message headers defined by RFC5322.
The set includes message headers indicating the network path taken by a message from the sender to the recipient.
It can also contain custom message headers that hold app data for the message.
Returned only on applying a $select query option.
Read-only.
[Name <String>]: Represents the key in a key-value pair.
[Value <String>]: The value in a key-value pair.
[InternetMessageId <String>]: The message ID in the format specified by RFC2822.
[IsDeliveryReceiptRequested <Boolean?>]: Indicates whether a read receipt is requested for the message.
[IsDraft <Boolean?>]: Indicates whether the message is a draft.
A message is a draft if it hasn't been sent yet.
[IsRead <Boolean?>]: Indicates whether the message has been read.
[IsReadReceiptRequested <Boolean?>]: Indicates whether a read receipt is requested for the message.
[MultiValueExtendedProperties <IMicrosoftGraphMultiValueLegacyExtendedProperty- []>]: The collection of multi-value extended properties defined for the message.
Nullable.
[Id <String>]: The unique identifier for an entity.
Read-only.
[Value <String- []>]: A collection of property values.
[ParentFolderId <String>]: The unique identifier for the message's parent mailFolder.
[ReceivedDateTime <DateTime?>]: The date and time the message was received.
The date and time information uses ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z.
[ReplyTo <IMicrosoftGraphRecipient- []>]: The email addresses to use when replying.
[Sender <IMicrosoftGraphRecipient>]: recipient
[SentDateTime <DateTime?>]: The date and time the message was sent.
The date and time information uses ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z.
[SingleValueExtendedProperties <IMicrosoftGraphSingleValueLegacyExtendedProperty- []>]: The collection of single-value extended properties defined for the message.
Nullable.
[Id <String>]: The unique identifier for an entity.
Read-only.
[Value <String>]: A property value.
[Subject <String>]: The subject of the message.
[ToRecipients <IMicrosoftGraphRecipient- []>]: The To: recipients for the message.
[UniqueBody <IMicrosoftGraphItemBody>]: itemBody
[WebLink <String>]: The URL to open the message in Outlook on the web.You can append an ispopout argument to the end of the URL to change how the message is displayed.
If ispopout is not present or if it is set to 1, then the message is shown in a popout window.
If ispopout is set to 0, the browser shows the message in the Outlook on the web review pane.The message opens in the browser if you are signed in to your mailbox via Outlook on the web.
You are prompted to sign in if you are not already signed in with the browser.This URL cannot be accessed from within an iFrame.