Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Message body missing? #18

Open
SPDEVGUY opened this issue May 26, 2017 · 1 comment
Open

Message body missing? #18

SPDEVGUY opened this issue May 26, 2017 · 1 comment

Comments

@SPDEVGUY
Copy link

Import-Module ".\gmail.ps\Gmail.ps.psm1"
Add-Type -Path '.\gmail.ps\AE.Net.Mail.dll'

$userName = "[YOUREMAIL]"
$password = "[YOURPASSWORD]"
$nc = New-Object System.Net.NetworkCredential($userName, $password); 
$creds = new-object PSCredential($nc.UserName, (ConvertTo-SecureString $nc.Password -AsPlainText -Force))

Invoke-GmailSession -credential $creds -ScriptBlock {
    param($gmail)
    $msgs = $gmail | Get-Mailbox | Get-Message -unread
	foreach($msg in $msgs)
	{
		$msg.From
		$msg.Body
	}
}


I'm receiving blanks /null for $msg.Body even though there is content within the bodies in gmail.

@SPDEVGUY
Copy link
Author

Solved it, the Prefetch option is not well documented.

Prefetch is usually used to just grab headers and not body content (in the code it passes !Prefetch into the HeadersOnly parameter on the GetMessage command. Which results in the body not being retrurned.

to fix it, I just added -prefetch on this line:
$msgs = $gmail | Get-Mailbox | Get-Message -unread -prefetch

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant