首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powershell EWS上传eml

Powershell EWS上传eml
EN

Stack Overflow用户
提问于 2013-05-14 22:10:33
回答 1查看 1.3K关注 0票数 1

我有这个代码来上传EML文件来交换。

代码语言:javascript
复制
#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和附件。

EN

回答 1

Stack Overflow用户

发布于 2013-09-12 20:13:55

编辑解决方案:Glen 在这里提供了一个解决方案:

22.html

替换Get内容:

[byte[]]$bdBinaryData1 = get-content -encoding byte "C:\temp\exportedmail.eml"

使用

[byte[]]$bdBinaryData1 = [System.IO.File]::ReadAllBytes("C:\temp\exportedmail.eml")

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16553684

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档