我使用以下命令解析我的电子邮件:
$EmailQuery = "$GraphURI/users/myemail@example.com/mailboxFolders/MyFolder/messages"
$EmailResponseFirst = Invoke-RestMethod -Method Get -Uri $EmailQuery -Headers @{Authorization = "Bearer $AccessToken"} -ContentType "application/json"
$EmailResponse = $EmailResponseFirst.value | Out-String
foreach ($Email in $EmailResponse) {
$RecipientAddress = $Email.toRecipients.emailAddress[0].emailAddress
Write-Host $RecipientAddress
它什么都不输出,但是如果我在脚本中附加以下内容:
Write-Host "($Email.from | ConvertFrom-Json).odata.etag"
我得到这个输出:
@odata.etag : W/"CQAAABYA"
id : AAMkADQ5M
createdDateTime : 2023-03-06T10:22:22Z
lastModifiedDateTime : 2023-03-06T10:22:24Z
changeKey : CQA
categories : {}
receivedDateTime : 2023-03-06T10:22:22Z
sentDateTime : 2023-03-06T10:22:18Z
hasAttachments : False
internetMessageId : <1BC4@sender.com>
subject : Test
bodyPreview : Test
importance : normal
parentFolderId : AAMkADQ
conversationId : AAQ
conversationIndex : AQHZ
isDeliveryReceiptRequested :
isReadReceiptRequested : False
isRead : True
isDraft : False
webLink : https://outlook.office365.com/owa/?ItemID=AAMk3D&exvsurl=1&viewmodel=ReadMessageItem
inferenceClassification : focused
body : @{contentType=html; content=<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>Test</body></html>}
sender : @{emailAddress=}
from : @{emailAddress=}
toRecipients : {@{emailAddress=}}
ccRecipients : {}
bccRecipients : {}
replyTo : {}
flag : @{flagStatus=notFlagged
如何从输出中获取“toRecipients”字段的值?
1条答案
按热度按时间umuewwlo1#
$response.value
是所有消息的数组。迭代所有消息,foreach消息迭代所有toRecipients
并编写它们的邮件