1
我有這段代碼來上傳EML文件進行交換。Powershell EWS上傳eml
#Upload Eml Sample
$folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
$Inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)
#Crete Email Object
$emUploadEmail = new-object Microsoft.Exchange.WebServices.Data.EmailMessage($service)
#Read File
[byte[]]$bdBinaryData1 = get-content -encoding byte "C:\temp\exportedmail.eml"
#Set Mime Content in Message
$emUploadEmail.MimeContent = new-object Microsoft.Exchange.WebServices.Data.MimeContent("us-ascii", $bdBinaryData1);
#Set Sent Message Flags which means message wont appear as a Draft
$PR_Flags = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(3591, [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Integer);
$emUploadEmail.SetExtendedProperty($PR_Flags,"1")
$emUploadEmail.Save($Inbox.Id)
當我嘗試上傳的EML文件與附件它會崩潰的計算機上運行的腳本。它需要所有的記憶。我如何修改上面的代碼來上傳eml和附件。