我可以使用Powershell使用REST API v1.0移动或复制消息(Office 365) [英] Can I move or copy messages (Office 365) using the REST API v1.0 using Powershell

查看:74
本文介绍了我可以使用Powershell使用REST API v1.0移动或复制消息(Office 365)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,非常感谢Fei Xue,我已经能够使用REST API发送电子邮件.我想知道的是,我可以在文件夹之间移动电子邮件吗?以下参考(使用V1.0)建议我可以..

So far, thanks kindly to Fei Xue, I have been able to send emails using the 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

我整理了一些东西,但是没有用.这些ID代表邮件ID和目标文件夹ID

I have put something together but its not working. The IDs represent the message ID and the destination folder 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..?

推荐答案

您得到的错误消息是什么?根据请求,$ uri似乎不正确.邮件ID不应包含?.

What's the error message you got? Based on the request, it seems that the $uri is not correct. The message id shouldn't contain the ?.

这是一个很好的要求供您参考:

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"

这篇关于我可以使用Powershell使用REST API v1.0移动或复制消息(Office 365)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆