Giter Club home page Giter Club logo

gmail.ps's Issues

Message Body is empty.

I want to use gmail.ps to parse some of the messages in my inbox, but it doesn't seem to pull the Body. I can see pretty much every other field (Headers, From, To, etc.), so I wonder if this is part of the work-in-progress?

Thanks!

Message body missing?

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.

Reading and displaying the content of the subject line

Maybe on the wrong place requested but I am new and dont now where to put it elswhere:

I like to read automaticly only the content (money value in $123.45 format) of the subjectline and show that info in an external counter.

Is Gmail.ps the right program for it?

If yes: Please give an example

Exception calling "SetFlags" with "2" argument(s): "BAD Invalid Arguments: Unable to parse flag \None"

Same setup as the previous:

Invoke-GmailSession -Credential $mycreds -ScriptBlock {
param($gmail)
$inbox = $gmail | Get-Mailbox
$messages = $inbox | Get-Message | Select-Object -Last 10
foreach ($msg in $messages) {
Update-Message -Session $gmail -Message $msg -Unread
}
}

I had a look in the Gmail.ps.psm1 and tried the -star -unstar flags - these worked fine - however the -Unread did not..

Complete exception:
Exception calling "SetFlags" with "2" argument(s): "BAD Invalid Arguments: Unable to parse flag \None"
At C:\Users[user]\Documents\WindowsPowerShell\Modules\Gmail.ps\Gmail.ps.psm1:563 char:64

  •             $Session.SetFlags([AE.Net.Mail.Flags]$flags, @($Message))
    
  •                                                            ~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : Exception

Get-Message doesn't work without any optional parameters

Would it make sense to have sensible defaults of $imap = @('SEEN','UNSEEN') if no other parameters are specified (I assume this will return all messages)?.

I can add a PR if that's a reasonable way to go about it.

The full exception:

PS C:\Users\administrator> $Session | Get-Mailbox 'Inbox' | Get-Message
Exception calling "Search" with "1" argument(s): "xm003 BAD Could not parse command"
At C:\Users\administrator\Documents\WindowsPowerShell\Modules\Gmail.ps\Gmail.ps.psm1:344 char:5
+     $result = $Session.Search('(' + $criteria + ')');
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : Exception

Move-Message Exception calling "MoveMessage" with "2" argument(s)

I'm getting an error calling Move-Message:

Exception calling "MoveMessage" with "2" argument(s): "NO [TRYCREATE] No folder All Mail (Failure)"

Full Code:
$gmail = New-GmailSession -Credential $Creds
$inbox = $gmail | Get-Mailbox
$msgs = $inbox | Get-Message -Read -Prefetch
$msgs[0] | Move-Message "All Mail" -Session $gmail

The All Mail folder definitely exists. I've tried the below command and it fines the folder fine:
$allMail = $gmail | Get-Mailbox "All Mail"

install.ps1 issues

When I try to install your module with the install.ps1 script i get this error.

C:\Users\Gamer\Documents\GitHub\Gmail.ps [master]> .\install.ps1
Import-Module : The 'C:\Users\Gamer\Documents\WindowsPowerShell\Modules\Gmail.p
s\Gmail.ps.psd1' module cannot be imported because its manifest contains one or
more members that are not valid. The valid manifest members are ('ModuleToProc
ess', 'NestedModules', 'GUID', 'Author', 'CompanyName', 'Copyright', 'ModuleVer
sion', 'Description', 'PowerShellVersion', 'PowerShellHostName', 'PowerShellHos
tVersion', 'CLRVersion', 'DotNetFrameworkVersion', 'ProcessorArchitecture', 'Re
quiredModules', 'TypesToProcess', 'FormatsToProcess', 'ScriptsToProcess', 'Priv
ateData', 'RequiredAssemblies', 'ModuleList', 'FileList', 'FunctionsToExport',
'VariablesToExport', 'AliasesToExport', 'CmdletsToExport'). Remove the members
that are not valid ('RootModule'), then try to import the module again.
At C:\Users\Gamer\Documents\GitHub\Gmail.ps\install.ps1:65 char:18

  • Import-Module <<<<  -Name $Destination\Gmail.ps
    
    • CategoryInfo : InvalidData: (C:\Users\Gamer...s\Gmail.ps.psd1:
      String) [Import-Module], InvalidOperationException
    • FullyQualifiedErrorId : Modules_InvalidManifestMember,Microsoft.PowerShe
      ll.Commands.ImportModuleCommand

Gmail.ps is installed and ready to use

Maybe i'm doing it wrong or missing some dependencies that are not mentioned. I haven't really looked into this issue since I currently don't have much powershell knowledge.

Remove-Message Permanently deleting emails

This may very well be a setting in the gmail inbox directly, but upon using the Remove-Message command, the message does not appear in the trash 'folder', it's simply gone gone.

Any clues?

Exception calling "Search" with "1" argument(s): "xm003 BAD Could not parse command

"Exception calling "Search" with "1" argument(s): "xm003 BAD Could not parse command"
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Gmail.ps\Gmail.ps.psm1:344 char:5

+ $result = $Session.Search('(' + $criteria + ')');
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : Exception
"
I have found that this happens if you use the following switches with any other parameters (
-Read** and -Unread).

This is because of an additional space after the criteria string on lines 254 & 256 of Gmail.ps\Gmail.ps.psm1

Kindly help correct these as soon as possible.
Great job.

Command Save-Attachment path not working as intended.

Hi,
I have been playing with gmail.ps these last few hours and I have been having issues with the save-attachment command. When I define a $folder = "c:/gmail/"
$gmail | Get-Mailbox -Label "Important" | Get-Message -Unread -HasAttachment -Prefetch | Save-Attachment $folder

the attachments go to the location of the ps1 script under the folder "c".
script location "c:/scripts/gmail.ps1"
location of attachments "c:/scripts/c/"
I was expecting the attachments to be located under "c:/gmail/".
Is this a bug or am I missing something?

Thanks in advance.
Johnty

Multiple ContentTypes in a single email

I'm trying to download a few particular messages, and they're coming down with a "text/plain" ContentType, basically saying to "enable HTML in your provider". If I View Original in Gmail, I see both the text/plain and text/html content (which is what I want). Am I doing something wrong, or missing something obvious? Thanks!

Can't use -On or -After in simple scripts on diff versions

I tried this on Powershell 2 and Powershell 4 on Windows Server 2008 and Windows 7 using different PCs.

This is a sample code:
$EmailUser = '[email protected]'
$EmailUser2 = '[email protected]'
$EmailSubject = "isAlive"
$pw = [System.Convert]::FromBase64String("Base64Password")
$pw = [System.Text.Encoding]::UTF8.GetString($pw)

$secpasswd = ConvertTo-SecureString $pw -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($EmailUser, $secpasswd)
$gmail = New-GmailSession -Credential $mycreds

$inbox = $gmail | Get-Mailbox
$inbox | Get-Message -Before "2014-11-30" ## This works fine.
$inbox | Get-Message -After "2014-11-30" ## This does not work.

Using -After gives us this error:

"Exception calling "Search" with "1" argument(s): "xm003 BAD Could not parse command"
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Gmail.ps\Gmail.ps.psm1:344 char:5

  • $result = $Session.Search('(' + $criteria + ')');
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : Exception
      "

Using -On gives us this error:
GetRFC2060Date : Cannot process argument transformation on parameter 'date'. Cannot convert null to type "System.DateTime".
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Gmail.ps\Gmail.ps.psm1:276 char:44

  •     $imap += 'ON "' + $(GetRFC2060Date $After) + '"'
    
  •                                        ~~~~~~
    
    • CategoryInfo : InvalidData: (:) [GetRFC2060Date], ParameterBindingArgumentTransformationException
    • FullyQualifiedErrorId : ParameterArgumentTransformationError,GetRFC2060Date"

Update-Message : Parameter set cannot be resolved using the specified named parameters.

First off - very nice, lightweight, scripting opportunities - couldn't find any other way of getting the body of the mails so effortlessly.

Maybe not a bug - but I tried to find the problem other places without luck.
Pretty much using the Readme.md example I am getting the error as shown above.

script is:
$secpasswd = ConvertTo-SecureString "---" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("---", $secpasswd)

Invoke-GmailSession -Credential $mycreds -ScriptBlock {
param($gmail)
$inbox = $gmail | Get-Mailbox
$messages = $inbox | Get-Message | Select-Object -Last 10
foreach ($msg in $messages) {
$msg | Update-Message -Unread
}
}

Am I doing it wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.