1
votes

I am working with Powershell third hour in my life.

I am downloading attachments from Exchange2010 based on this script: http://gsexdev.blogspot.nl/2010/01/writing-simple-scripted-process-to.html

Right now there are set these variables concerning email set-up:

$MailboxName = "[email protected]"
$Sender = "[email protected]"

Later on are these variables used as conditions for action: IF new email is in "[email protected]" and sender is "[email protected]" then do some steps.

  $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: does SENDER column in itemschema exist? I didnt find it here:
https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.itemschema_members(v=exchg.80).aspx

I would like to extend these conditions on Subject of email. This means: IF new email is in "[email protected]" and sender is "[email protected]" AND subject is LIKE "&BETA&" then do some steps.

I thought I would do st like this:

#$Subjecthelp = ".csv"            

And then I would do :

#$Sfsub = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+**LIKE**([Microsoft.Exchange.WebServices.Data.ItemSchema]::Subject, $Subject)

But it does not really work and I do really know how to write it :)

1

1 Answers

1
votes

You're probably looking for:

$Sfsub = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+ContainsSubstring([Microsoft.Exchange.WebServices.Data.ItemSchema]::Subject, $Subject)

You can find the supported filters in the documentation