简体   繁体   English

我可以使用Powershell使用REST API v1.0移动或复制消息(Office 365)

[英]Can I move or copy messages (Office 365) using the REST API v1.0 using Powershell

So far, thanks kindly to Fei Xue, I have been able to send emails using the REST API. 到目前为止,感谢Fei Xue,我已经能够使用REST API发送电子邮件。 What I would like to know is can I move emails between folders. 我想知道的是我可以在文件夹之间移动电子邮件吗? The following reference (using V1.0) suggests I can.. https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations#Moveorcopymessages 以下参考(使用V1.0)建议我可以.. https://msdn.microsoft.com/zh-cn/office/office365/api/mail-rest-operations#Moveorcopymessages

I have put something together but its not working. 我已经整理了一些东西,但是没有用。 The IDs represent the message ID and the destination folder ID 这些ID表示邮件ID和目标文件夹ID

$contentType = "application/json"
$uri = "https://outlook.office365.com/api/v1.0/me/messages/AAMkADRjZmU1Njg3LWU1MTgtNDRlYS1hM2JjLThjYzVlYTNiYjI2NQBGAAAAAACnOSYQcbEERIZTVx5HtMm9BwDzVgO1bziCQLdugqQvOwrTAEVv8cxtAACxp0cQeSQxTYONMj3glZFxAAIF_5u4AAA=?/move"

$body = @{
DestinationID = "AAMkADRjZmU1Njg3LWU1MTgtNDRlYS1hM2JjLThjYzVlYTNiYjI2NQAuAAAAAACnOSYQcbEERIZTVx5HtMm9AQCxp0cQeSQxTYONMj3glZFxAAGmgyRMAAA="
}
$json = $body | ConvertTo-Json
Invoke-RestMethod -Uri $uri -Method Post -Credential $cred -Body $json -ContentType $contentType

Since I can send emails, I would have thought I can move them..? 由于我可以发送电子邮件,所以我本以为可以移动它们。

What's the error message you got? 您收到什么错误消息? Based on the request, it seems that the $uri is not correct. 根据请求,$ uri似乎不正确。 The message id shouldn't contain the ? 邮件ID不应包含 .

Here is an request works welll for your reference: 这是一个很好的要求供您参考:

$body="{""DestinationId"":""AQMkADQyZjE2NzY3LWEyNjEtNGI3NwAtOWJhOS1jN2I5NTdkYmY4NmEALgAAA6N9fgB38JpAkbQ1i6fbzV8BAL3QnQZrC1lNpUx8h1pAnzAAAAIBCgAAAA==""}

Invoke-RestMethod -Method post -uri "https://outlook.office365.com/api/v1.0/me/messages/AAMkADQyZjE2NzY3LWEyNjEtNGI3Ny05YmE5LWM3Yjk1N2RiZjg2YQBGAAAAAACjfX4Ad-CaQJG0NYun281fBwC90J0GawtZTaVMfIdaQJ8wAAAAAAEMAAC90J0GawtZTaVMfIdaQJ8wAAFYk-FGAAA=/move" -Credential $cred -Body $body -ContentType "application/json"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM