我有这个代码来上传 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 和附件。