Send-MgUserMail

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:\n- Provide the applicable Internet message headers and the MIME content, all encoded in base64 format in the request body.\n- Add any attachments and S/MIME properties to the MIME content. 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.

Syntax

Send-MgUserMail
    -UserId <String>
    [-AdditionalProperties <Hashtable>]
    [-Message <IMicrosoftGraphMessage1>]
    [-SaveToSentItems]
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
Send-MgUserMail
    -UserId <String>
    -BodyParameter <IComponentsVsh1S1RequestbodiesSendmailrequestbodyContentApplicationJsonSchema>
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
Send-MgUserMail
    -InputObject <IUsersActionsIdentity>
    [-AdditionalProperties <Hashtable>]
    [-Message <IMicrosoftGraphMessage1>]
    [-SaveToSentItems]
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
Send-MgUserMail
    -InputObject <IUsersActionsIdentity>
    -BodyParameter <IComponentsVsh1S1RequestbodiesSendmailrequestbodyContentApplicationJsonSchema>
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

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:\n- Provide the applicable Internet message headers and the MIME content, all encoded in base64 format in the request body.\n- Add any attachments and S/MIME properties to the MIME content. 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.

Examples

Example 1: Using the Send-MgUserMail Cmdlet

Import-Module Microsoft.Graph.Users.Actions
$params = @{
	Message = @{
		Subject = "Meet for lunch?"
		Body = @{
			ContentType = "Text"
			Content = "The new cafeteria is open."
		}
		ToRecipients = @(
			@{
				EmailAddress = @{
					Address = "fannyd@contoso.onmicrosoft.com"
				}
			}
		)
		CcRecipients = @(
			@{
				EmailAddress = @{
					Address = "danas@contoso.onmicrosoft.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. To learn about permissions for this resource, see the permissions reference.

Example 2: Using the Send-MgUserMail Cmdlet

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.onmicrosoft.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. To learn about permissions for this resource, see the permissions reference.

Example 3: Using the Send-MgUserMail Cmdlet

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.OnMicrosoft.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. To learn about permissions for this resource, see the permissions reference.

Parameters

-AdditionalProperties

Additional Parameters

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-BodyParameter

. To construct, please use Get-Help -Online and see NOTES section for BODYPARAMETER properties and create a hash table.

Type:IComponentsVsh1S1RequestbodiesSendmailrequestbodyContentApplicationJsonSchema
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

Identity Parameter To construct, please use Get-Help -Online and see NOTES section for INPUTOBJECT properties and create a hash table.

Type:IUsersActionsIdentity
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-Message

message To construct, please use Get-Help -Online and see NOTES section for MESSAGE properties and create a hash table.

Type:IMicrosoftGraphMessage1
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-PassThru

Returns true when the command succeeds

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-SaveToSentItems

.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-UserId

key: id of user

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.Graph.PowerShell.Models.IComponentsVsh1S1RequestbodiesSendmailrequestbodyContentApplicationJsonSchema

Microsoft.Graph.PowerShell.Models.IUsersActionsIdentity

Outputs

System.Boolean

Notes

ALIASES

COMPLEX PARAMETER PROPERTIES

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.

BODYPARAMETER <IComponentsVsh1S1RequestbodiesSendmailrequestbodyContentApplicationJsonSchema>: .

  • [(Any) <Object>]: This indicates any property can be added to this object.
  • [Message <IMicrosoftGraphMessage1>]: 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 idenfier for an entity. Read-only.
    • [Attachments <IMicrosoftGraphAttachment[]>]: The fileAttachment and itemAttachment attachments for the message.
      • [Id <String>]: The unique idenfier 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.
      • [EmailAddress <IMicrosoftGraphEmailAddress>]: emailAddress
        • [(Any) <Object>]: This indicates any property can be added to this object.
        • [Address <String>]: The email address of the person or entity.
        • [Name <String>]: The display name of the person or entity.
    • [Body <IMicrosoftGraphItemBody>]: itemBody
      • [(Any) <Object>]: This indicates any property can be added to this object.
      • [Content <String>]: The content of the item.
      • [ContentType <String>]: bodyType
    • [BodyPreview <String>]: The first 255 characters of the message body. It is in text format.
    • [CcRecipients <IMicrosoftGraphRecipient[]>]: The Cc: recipients for the message.
    • [ConversationId <String>]: The ID of the conversation the email belongs to.
    • [ConversationIndex <Byte[]>]: Indicates the position of the message within the conversation.
    • [Extensions <IMicrosoftGraphExtension[]>]: The collection of open extensions defined for the message. Nullable.
      • [Id <String>]: The unique idenfier for an entity. Read-only.
    • [Flag <IMicrosoftGraphFollowupFlag>]: followupFlag
      • [(Any) <Object>]: This indicates any property can be added to this object.
      • [CompletedDateTime <IMicrosoftGraphDateTimeZone>]: dateTimeTimeZone
        • [(Any) <Object>]: This indicates any property can be added to this object.
        • [DateTime <String>]: A single point of time in a combined date and time representation ({date}T{time}; for example, 2017-08-29T04:00:00.0000000).
        • [TimeZone <String>]: Represents a time zone, for example, 'Pacific Standard Time'. See below for more possible values.
      • [DueDateTime <IMicrosoftGraphDateTimeZone>]: dateTimeTimeZone
      • [FlagStatus <String>]: followupFlagStatus
      • [StartDateTime <IMicrosoftGraphDateTimeZone>]: dateTimeTimeZone
    • [From <IMicrosoftGraphRecipient>]: recipient
    • [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 .
    • [Importance <String>]: importance
    • [InferenceClassification <String>]: inferenceClassificationType
    • [InternetMessageHeaders <IMicrosoftGraphInternetMessageHeader[]>]:
      • [Name <String>]: Represents the key in a key-value pair.
      • [Value <String>]: The value in a key-value pair.
    • [InternetMessageId <String>]:
    • [IsDeliveryReceiptRequested <Boolean?>]:
    • [IsDraft <Boolean?>]:
    • [IsRead <Boolean?>]:
    • [IsReadReceiptRequested <Boolean?>]:
    • [MultiValueExtendedProperties <IMicrosoftGraphMultiValueLegacyExtendedProperty[]>]: The collection of multi-value extended properties defined for the message. Nullable.
      • [Id <String>]: The unique idenfier for an entity. Read-only.
      • [Value <String[]>]: A collection of property values.
    • [ParentFolderId <String>]:
    • [ReceivedDateTime <DateTime?>]:
    • [ReplyTo <IMicrosoftGraphRecipient[]>]:
    • [Sender <IMicrosoftGraphRecipient>]: recipient
    • [SentDateTime <DateTime?>]:
    • [SingleValueExtendedProperties <IMicrosoftGraphSingleValueLegacyExtendedProperty[]>]: The collection of single-value extended properties defined for the message. Nullable.
      • [Id <String>]: The unique idenfier for an entity. Read-only.
      • [Value <String>]: A property value.
    • [Subject <String>]:
    • [ToRecipients <IMicrosoftGraphRecipient[]>]:
    • [UniqueBody <IMicrosoftGraphItemBody>]: itemBody
    • [WebLink <String>]:
  • [SaveToSentItems <Boolean?>]:

INPUTOBJECT <IUsersActionsIdentity>: Identity Parameter

  • [AccessReviewInstanceId <String>]: key: id of accessReviewInstance
  • [AccessReviewStageId <String>]: key: id of accessReviewStage
  • [AppLogCollectionRequestId <String>]: key: id of appLogCollectionRequest
  • [AuthenticationMethodId <String>]: key: id of authenticationMethod
  • [BaseTaskId <String>]: key: id of baseTask
  • [BaseTaskListId <String>]: key: id of baseTaskList
  • [CalendarId <String>]: key: id of calendar
  • [ChatId <String>]: key: id of chat
  • [ChatMessageId <String>]: key: id of chatMessage
  • [ChatMessageId1 <String>]: key: id of chatMessage
  • [CloudPcId <String>]: key: id of cloudPC
  • [ContentTypeId <String>]: key: id of contentType
  • [DeviceEnrollmentConfigurationId <String>]: key: id of deviceEnrollmentConfiguration
  • [DeviceId <String>]: key: id of device
  • [DeviceLogCollectionResponseId <String>]: key: id of deviceLogCollectionResponse
  • [DocumentSetVersionId <String>]: key: id of documentSetVersion
  • [DriveId <String>]: key: id of drive
  • [DriveItemId <String>]: key: id of driveItem
  • [DriveItemVersionId <String>]: key: id of driveItemVersion
  • [EventId <String>]: key: id of event
  • [EventId1 <String>]: key: id of event
  • [ListItemId <String>]: key: id of listItem
  • [ListItemVersionId <String>]: key: id of listItemVersion
  • [MailFolderId <String>]: key: id of mailFolder
  • [MailFolderId1 <String>]: key: id of mailFolder
  • [ManagedDeviceId <String>]: key: id of managedDevice
  • [MessageId <String>]: key: id of message
  • [MicrosoftAuthenticatorAuthenticationMethodId <String>]: key: id of microsoftAuthenticatorAuthenticationMethod
  • [MobileAppTroubleshootingEventId <String>]: key: id of mobileAppTroubleshootingEvent
  • [NotebookId <String>]: key: id of notebook
  • [OnenotePageId <String>]: key: id of onenotePage
  • [OnenoteSectionId <String>]: key: id of onenoteSection
  • [OutlookTaskFolderId <String>]: key: id of outlookTaskFolder
  • [OutlookTaskGroupId <String>]: key: id of outlookTaskGroup
  • [OutlookTaskId <String>]: key: id of outlookTask
  • [PasswordlessMicrosoftAuthenticatorAuthenticationMethodId <String>]: key: id of passwordlessMicrosoftAuthenticatorAuthenticationMethod
  • [PermissionId <String>]: key: id of permission
  • [PhoneAuthenticationMethodId <String>]: key: id of phoneAuthenticationMethod
  • [ResourceSpecificPermissionGrantId <String>]: key: id of resourceSpecificPermissionGrant
  • [SensitivityLabelId <String>]: key: id of sensitivityLabel
  • [SubscriptionId <String>]: key: id of subscription
  • [TeamsAppInstallationId <String>]: key: id of teamsAppInstallation
  • [TodoTaskId <String>]: key: id of todoTask
  • [TodoTaskListId <String>]: key: id of todoTaskList
  • [UserId <String>]: key: id of user
  • [WindowsHelloForBusinessAuthenticationMethodId <String>]: key: id of windowsHelloForBusinessAuthenticationMethod

MESSAGE <IMicrosoftGraphMessage1>: 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 idenfier for an entity. Read-only.
  • [Attachments <IMicrosoftGraphAttachment[]>]: The fileAttachment and itemAttachment attachments for the message.
    • [Id <String>]: The unique idenfier 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.
    • [EmailAddress <IMicrosoftGraphEmailAddress>]: emailAddress
      • [(Any) <Object>]: This indicates any property can be added to this object.
      • [Address <String>]: The email address of the person or entity.
      • [Name <String>]: The display name of the person or entity.
  • [Body <IMicrosoftGraphItemBody>]: itemBody
    • [(Any) <Object>]: This indicates any property can be added to this object.
    • [Content <String>]: The content of the item.
    • [ContentType <String>]: bodyType
  • [BodyPreview <String>]: The first 255 characters of the message body. It is in text format.
  • [CcRecipients <IMicrosoftGraphRecipient[]>]: The Cc: recipients for the message.
  • [ConversationId <String>]: The ID of the conversation the email belongs to.
  • [ConversationIndex <Byte[]>]: Indicates the position of the message within the conversation.
  • [Extensions <IMicrosoftGraphExtension[]>]: The collection of open extensions defined for the message. Nullable.
    • [Id <String>]: The unique idenfier for an entity. Read-only.
  • [Flag <IMicrosoftGraphFollowupFlag>]: followupFlag
    • [(Any) <Object>]: This indicates any property can be added to this object.
    • [CompletedDateTime <IMicrosoftGraphDateTimeZone>]: dateTimeTimeZone
      • [(Any) <Object>]: This indicates any property can be added to this object.
      • [DateTime <String>]: A single point of time in a combined date and time representation ({date}T{time}; for example, 2017-08-29T04:00:00.0000000).
      • [TimeZone <String>]: Represents a time zone, for example, 'Pacific Standard Time'. See below for more possible values.
    • [DueDateTime <IMicrosoftGraphDateTimeZone>]: dateTimeTimeZone
    • [FlagStatus <String>]: followupFlagStatus
    • [StartDateTime <IMicrosoftGraphDateTimeZone>]: dateTimeTimeZone
  • [From <IMicrosoftGraphRecipient>]: recipient
  • [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 .
  • [Importance <String>]: importance
  • [InferenceClassification <String>]: inferenceClassificationType
  • [InternetMessageHeaders <IMicrosoftGraphInternetMessageHeader[]>]:
    • [Name <String>]: Represents the key in a key-value pair.
    • [Value <String>]: The value in a key-value pair.
  • [InternetMessageId <String>]:
  • [IsDeliveryReceiptRequested <Boolean?>]:
  • [IsDraft <Boolean?>]:
  • [IsRead <Boolean?>]:
  • [IsReadReceiptRequested <Boolean?>]:
  • [MultiValueExtendedProperties <IMicrosoftGraphMultiValueLegacyExtendedProperty[]>]: The collection of multi-value extended properties defined for the message. Nullable.
    • [Id <String>]: The unique idenfier for an entity. Read-only.
    • [Value <String[]>]: A collection of property values.
  • [ParentFolderId <String>]:
  • [ReceivedDateTime <DateTime?>]:
  • [ReplyTo <IMicrosoftGraphRecipient[]>]:
  • [Sender <IMicrosoftGraphRecipient>]: recipient
  • [SentDateTime <DateTime?>]:
  • [SingleValueExtendedProperties <IMicrosoftGraphSingleValueLegacyExtendedProperty[]>]: The collection of single-value extended properties defined for the message. Nullable.
    • [Id <String>]: The unique idenfier for an entity. Read-only.
    • [Value <String>]: A property value.
  • [Subject <String>]:
  • [ToRecipients <IMicrosoftGraphRecipient[]>]:
  • [UniqueBody <IMicrosoftGraphItemBody>]: itemBody
  • [WebLink <String>]: