Move Email Attachment to another folder using powershell


up until given assignment last week had never heard of powershell.  move emails attachments such pdf different folder.  found tutorial on how move emails subject line , works can not figure out how weed out pdf.  here code move subject line.  awesome.

 add-type -assembly "microsoft.office.interop.outlook"
 $outlook = new-object -comobject outlook.application
 $namespace = $outlook.getnamespace("mapi")
 $inbox =
   $namespace.getdefaultfolder([microsoft.office.interop.outlook.oldefaultfolders]::olfolderinbox)
 $myfolder1 =
   $namespace.folders.item('cander@mycompany.com').folders.item('aa_reports_pdf')
 $rules = $namespace.defaultstore.getrules()
 $rule = $rules.create("my rule1: notification",
   [microsoft.office.interop.outlook.olruletype]::olrulereceive)
   $rule_body = $rule.conditions.subject
 $rule_body.enabled = $true
 $rule_body.text = @('notification')
 $action = $rule.actions.movetofolder
 $action.enabled = $true
   [microsoft.office.interop.outlook._moveorcopyruleaction].invokemember(
     "folder",
     [system.reflection.bindingflags]::setproperty,
     $null,
     $action,
     $myfolder1)
 $rules.save()

you have attachments , see are.

learn how enumerate mail items in inbox , inspect them. once can rest easy.

the method trying use not useful finding attachment.


\_(ツ)_/



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file