< Back
Add-MgaMailAttachment
Post
NAME Add-MgaMailAttachment
SYNOPSIS
Add attachment(s) to a draft message in Exchange Online using the graph api.
SYNTAX
Add-MgaMailAttachment [-Message] <MessageParameter[]> -File <String[]> [-Force] [-User <String>] [-Token
<AzureAccessToken>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
Add-MgaMailAttachment [-Message] <MessageParameter[]> -Link <ReferenceAttachment[]> [-Force] [-User <String>]
[-Token <AzureAccessToken>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
Add-MgaMailAttachment [-Message] <MessageParameter[]> -Item <PSObject[]> [-Force] [-User <String>] [-Token
<AzureAccessToken>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
Add attachment(s) to a draft message in Exchange Online using the graph api.
Currently, only file attachments are supportet.
PARAMETERS
-Message <MessageParameter[]>
Carrier object for Pipeline input.
This can be the id of the message or a message object passed in.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-File <String[]>
The path to the file to add as attachment.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Link <ReferenceAttachment[]>
The ReferenceAttachment (aka "modern attachment", aka OneDriveLink) to add to the message..
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Item <PSObject[]>
The Outlook item to add as attachment.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Force [<SwitchParameter>]
Enforce adding attachment, even when the message is not in draft mode.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-User <String>
The user-account to access. Defaults to the main user connected as.
Can be any primary email name of any user the connected token has access to.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Token <AzureAccessToken>
The token representing an established connection to the Microsoft Graph Api.
Can be created by using New-MgaAccessToken.
Can be omitted if a connection has been registered using the -Register parameter on New-MgaAccessToken.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-PassThru [<SwitchParameter>]
Outputs the token to the console
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
If this switch is enabled, no actions are performed but informational messages will be displayed that explain
what would happen if the command were to run.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
If this switch is enabled, you will be prompted for confirmation before executing any operations that change
state.
Required? false
Position? named
Default value
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
OUTPUTS
NOTES
For addiontional information about Microsoft Graph API go to:
https://docs.microsoft.com/en-us/graph/ ... h-rest-1.0
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$mail | Add-MgaMailAttachment -Path "logfile.txt"
Add "logfile.txt" as attachment to message(s) in the variable $mail,
The variable $mails can be represent:
PS C:\\> $mails = Get-MgaMailMessage -Folder Drafts -ResultSize 1
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>$mail | Add-MgaMailAttachment -Link $ReferenceAttachment
Add a modern attachment as attachment (reference link) to message(s) in the variable $mail,
The variable $mails can be represent:
PS C:\\> $mails = Get-MgaMailMessage -Folder Drafts -ResultSize 1
The variable $ReferenceAttachment has to be a object [MSGraph.Exchange.Attachment.ReferenceAttachment]
RELATED LINKS
SYNOPSIS
Add attachment(s) to a draft message in Exchange Online using the graph api.
SYNTAX
Add-MgaMailAttachment [-Message] <MessageParameter[]> -File <String[]> [-Force] [-User <String>] [-Token
<AzureAccessToken>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
Add-MgaMailAttachment [-Message] <MessageParameter[]> -Link <ReferenceAttachment[]> [-Force] [-User <String>]
[-Token <AzureAccessToken>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
Add-MgaMailAttachment [-Message] <MessageParameter[]> -Item <PSObject[]> [-Force] [-User <String>] [-Token
<AzureAccessToken>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
Add attachment(s) to a draft message in Exchange Online using the graph api.
Currently, only file attachments are supportet.
PARAMETERS
-Message <MessageParameter[]>
Carrier object for Pipeline input.
This can be the id of the message or a message object passed in.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-File <String[]>
The path to the file to add as attachment.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Link <ReferenceAttachment[]>
The ReferenceAttachment (aka "modern attachment", aka OneDriveLink) to add to the message..
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Item <PSObject[]>
The Outlook item to add as attachment.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Force [<SwitchParameter>]
Enforce adding attachment, even when the message is not in draft mode.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-User <String>
The user-account to access. Defaults to the main user connected as.
Can be any primary email name of any user the connected token has access to.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Token <AzureAccessToken>
The token representing an established connection to the Microsoft Graph Api.
Can be created by using New-MgaAccessToken.
Can be omitted if a connection has been registered using the -Register parameter on New-MgaAccessToken.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-PassThru [<SwitchParameter>]
Outputs the token to the console
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
If this switch is enabled, no actions are performed but informational messages will be displayed that explain
what would happen if the command were to run.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
If this switch is enabled, you will be prompted for confirmation before executing any operations that change
state.
Required? false
Position? named
Default value
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
OUTPUTS
NOTES
For addiontional information about Microsoft Graph API go to:
https://docs.microsoft.com/en-us/graph/ ... h-rest-1.0
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$mail | Add-MgaMailAttachment -Path "logfile.txt"
Add "logfile.txt" as attachment to message(s) in the variable $mail,
The variable $mails can be represent:
PS C:\\> $mails = Get-MgaMailMessage -Folder Drafts -ResultSize 1
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>$mail | Add-MgaMailAttachment -Link $ReferenceAttachment
Add a modern attachment as attachment (reference link) to message(s) in the variable $mail,
The variable $mails can be represent:
PS C:\\> $mails = Get-MgaMailMessage -Folder Drafts -ResultSize 1
The variable $ReferenceAttachment has to be a object [MSGraph.Exchange.Attachment.ReferenceAttachment]
RELATED LINKS