none
PowerShell and EWS Managed API: how to attach an existing ItemAttachment to a new EmailMessage? RRS feed

  • Question

  • Hello!

    Is it possible to attach an existing ItemAttachment to a new EmailMessage in PowerShell?

    foreach ($Item in $FindResults.Items)
    {
    	$Message = New-Object Microsoft.Exchange.WebServices.Data.EmailMessage($Service)
    
    	if ($Item.HasAttachments)
    	{
    		foreach ($Attachment in $Item.Attachments)
    		{
    			$Attachment.Load()
    
    			if ($Attachment -is [Microsoft.Exchange.WebServices.Data.FileAttachment])
    			{
    				[Void]$Message.Attachments.AddFileAttachment($Attachment.Name, $Attachment.Content)
    			}
    			elseif ($Attachment -is [Microsoft.Exchange.WebServices.Data.ItemAttachment])
    			{
    				# How to add an ItemAttachment to a new message?
    			}
    		}
    	}
    }
    


     

    Tuesday, July 26, 2011 12:35 PM