Renaming Attachments using Powershell and Exchange WebServices RRS feed

  • Question

  • I thought this would be simple but I haven't found the solution myself yet.  I'm just simply trying to run through each attachment in an email and rename them to my own specified format.  Currently I am just trying to rename the attachment to anything.  But, this errors out and does not work.  Does anyone have a solution for this?

        $fiItems = $Inbox.FindItems($Sfha,$ivItemView)   
            foreach($Item in $fiItems.Items){        
                # Move the Message  
    			$hasAttachment = $false
    			foreach($attach in $Item.Attachments){
    					$attach.Name = "test"
    					# attach.Name = "" AND attach.Name("") both do not work
    					$hasAttachment = $true
    			if($hasAttachment -eq $true){
            $ivItemView.Offset += $fiItems.Items.Count    
        }while($fiItems.MoreAvailable -eq $true)  

    Wednesday, September 23, 2015 2:36 PM

All replies

  • EWS doesn't support updating properties on Attachments (after submit, eg you can do it before a message is sent or created), you would have to remove the attachment and then re-add it to do it with EWS on a existing item. You can do with it with MAPI without the remove/add eg using something like Redemption would work in Powershell (make sure you match the bitness of powershell and outlook)


    Thursday, September 24, 2015 5:28 AM