我在职业生涯第三个小时与Powershell合作。
我正在根据此脚本从Exchange2010下载附件:http://gsexdev.blogspot.nl/2010/01/writing-simple-scripted-process-to.html
现在设置有关电子邮件设置的变量:
$MailboxName = "email@email.net"
$Sender = "sender@email.com"
稍后将这些变量用作行动条件: 如果新电子邮件在" email@email.net"发件人是" sender@email.com"然后做一些步骤。
$folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
$InboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)
$Sfir = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::IsRead, $false)
$Sfsen = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.ItemSchema]::Sender, $Sender)
BTW:itemschema中的SENDER列是否存在?我在这里找不到:
https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.itemschema_members(v=exchg.80).aspx
我想在电子邮件的主题上扩展这些条件。这意味着: 如果新电子邮件在" email@email.net"发件人是" sender@email.com" AND主题是LIKE" & BETA& " 然后执行一些步骤。
我以为我会这样做:
#$Subjecthelp = ".csv"
然后我会这样做:
#$Sfsub = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+**LIKE**([Microsoft.Exchange.WebServices.Data.ItemSchema]::Subject, $Subject)
但它确实不起作用,我确实知道如何写它:)
答案 0 :(得分:1)
你可能正在寻找:
$Sfsub = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+ContainsSubstring([Microsoft.Exchange.WebServices.Data.ItemSchema]::Subject, $Subject)
您可以在documentation
中找到支持的过滤器