Reputation: 2291
Trying to Read a string in Powershell from an email with IMAP connect:
I use the Mail.dll from http://www.limilabs.com/mail/ Docu: http://www.limilabs.com/mail/documentation/
I want to search for a specific Subject.
What i have so far:
[Reflection.Assembly]::LoadFile("c:\mail.dll")
$imap = new-object Limilabs.Client.IMAP.Imap
$imap.Connect("192.168.0.1")
$imap.User = "user"
$imap.Password = "xxxx"
$imap.login()
$imap.Select("Inbox.folder.subfolder") #instead of $imap.selectinbox() i select a subfolder
$imap.GetMessage()
$imap.GetMessage() now lists one email, i think the last one.. but i want one with a specific subject.
The Doku gives following example but i am not able to handle this im Powershell:
List<long> uids = imap.Search().Where(Expression.Subject("report")).Sort(SortBy.Date()).GetUIDList();
I think i probably went in trouble with my tests because the "Where" is also a native Posh-Command... It always ended in a missing ) error ...
Upvotes: 1
Views: 2488
Reputation: 202002
It looks like these methods are neither static extension methods nor generic methods. I'd say you just need help converting this C# syntax to PowerShell:
List<long> uids = imap.Search().Where(Expression.Subject("report")).Sort(SortBy.Date()).GetUIDList();
First up, the C# generic syntax doesn't work in PowerShell and the syntax for invoking static methods is different. Try something like this:
$report = [Limilabs.Client.IMAP.Expression]::Subject("report")
$sorter = [Limilabs.Client.IMAP.SortBy]::Date()
$uids = $imap.Search().Where($report).Sort($sorter).GetUIDList()
Upvotes: 0
Reputation: 6391
I'm not a PowerShell expert, but this works:
$Expression = [Limilabs.Client.IMAP.Expression]
$uids = $imap.Search().Where($Expression::Subject("report")).GetUIDList()
foreach ($uid in $uids ) { $imap.GetMessageByUID($uid) }
Please also note that Sort extension is rarely supported by IMAP servers.
Upvotes: 1