-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for downloading inline images using the -SaveAttachmentsTo parameter #209
Comments
Thanks, @higginsta !! Sample code for (my own) reference that was shared on Discord: Import-Module PSGSuite
$msg = Get-GSGmailMessage -Id $id -Verbose -ParseMessage
$downloadPath = "~\Downloads"
foreach ($att in ($msg.BodyParts | Where-Object {$_.FileName})) {
$cleanedName = $att.FileName -replace "[$([RegEx]::Escape("$(([System.IO.Path]::GetInvalidFileNameChars() + [System.IO.Path]::GetInvalidPathChars()) -join '')"))]","_"
$resPath = (Resolve-Path $downloadPath).Path
$fileName = Join-Path $resPath $cleanedName
Write-Verbose "Saving attachment to path '$fileName'"
$stream = [System.IO.File]::Create($fileName)
$att.ContentObject.DecodeTo($stream)
$stream.Close()
} |
hey @higginsta - This is fixed and confirmed working as expected! The behavior now is that it will grab both BodyParts and Attachments that have a FileName listed for them, then sort by unique FileName + ContentId, then download the resulting list to the path specified in |
I'll let you know as soon as available on the Gallery! |
## 2.30.0 * [Issue #193](#193) * Added: Drive Revision functions: * Get-GSDriveRevision * Remove-GSDriveRevision * Update-GSDriveRevision * [Issue #210](#210) * Fixed: Update-GSUser was not accepting User ID's as the User parameter * [Issue #209](#209) * Added: Support for inline image downloading with Get-GSGmailMessage where the image is not included on the Attachments property of the parsed message object. * Fixed: Get-GSGmailMessage will now automatically set the Format to Raw if either ParseMessage or SaveAttachmentsTo is passed, as ParseMessage is a requirement in order to be able to access the message attachments as needed. * [Issue #204](#204) * Added: Recurse parameter to Get-GSDriveFileList to allow recursively listing all files and subfolders underneath the result set. Confirmed setting the Limit parameter also works as expected with Recurse included, stopping is the original limit is reached. * Added: Get-GSDriveFolderSize function to return the calculated total size of the files in the specified folder(s). * Miscellaneous * Added: Rfc822MsgId parameter to Get-GSGmailMessageList to easily build a query looking for a specific RFS 822 Message ID. * Added: Pipeline support for *-GSDrivePermission functions to enable piping Drive Files into them to manage permissions without looping manually.
## 2.30.0 * [Issue #193](#193) * Added: Drive Revision functions: * `Get-GSDriveRevision` * `Remove-GSDriveRevision` * `Update-GSDriveRevision` * [Issue #210](#210) * Fixed: `Update-GSUser` was not accepting User ID's as the User parameter * [Issue #209](#209) * Added: Support for inline image downloading with `Get-GSGmailMessage` where the image is not included on the Attachments property of the parsed message object. * Fixed: `Get-GSGmailMessage` will now automatically set the `Format` to `Raw` if either `ParseMessage` or `SaveAttachmentsTo` is passed, as `ParseMessage` is a requirement in order to be able to access the message attachments as needed. * [Issue #204](#204) * Added: `Recurse` parameter to `Get-GSDriveFileList` to allow recursively listing all files and subfolders underneath the result set. Confirmed setting the `Limit` parameter also works as expected with `Recurse` included, stopping is the original limit is reached. * Added: `Get-GSDriveFolderSize` function to return the calculated total size of the files in the specified folder(s). * Miscellaneous * Added: `Rfc822MsgId` parameter to `Get-GSGmailMessageList` to easily build a query looking for a specific RFS 822 Message ID. * Added: Pipeline support for `*-GSDrivePermission` functions to enable piping Drive Files into them to manage permissions without looping manually.
deployed! |
Is your feature request related to a problem? Please describe.
The
-SaveAttachmentsTo
parameter does not work for all messages that contain inline images. Some email clients like iPhone Mail do not specify inline images as being attachments.Describe the solution you'd like
Please add the ability for the
-SaveAttachmentsTo
parameter to parse files that are included inline with a message (located withinBodyParts
instead ofAttachments
)Describe alternatives you've considered
The sample code you provided as a workaround for inline images works as expected.
Additional context
You helped me work through this issue via Discord on July 10th, 2019 (using code similar to what Get-GSGmailMessage is already doing)
The text was updated successfully, but these errors were encountered: