从Azure Powershell访问Outlook电子邮件

时间:2018-02-15 15:17:35

标签: powershell azure outlook azure-powershell

我的要求是使用Azure Powershell检查特定电子邮件是否到达我的收件箱。我能够使用Microsoft.Office.Interop.Outlook.olDefaultFolders从Windows Powershell成功完成此操作。

以下是Windows PowerShell使用的代码,希望从Azure Powershell实现相同的功能。难点是从Azure Powershell连接到Outlook服务器。

$currentDate = Get-Date
$olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [Type]
$outlook = new-object -ComObject outlook.application
$namespace = $outlook.GetNamespace("MAPI")
$folder = $namespace.GetDefaultFolder(6).Folders("MySubFolder")
$folder.Items |  ForEach {
    If ($_.subject -match "Server Daily Status") 
    {
        If ($_.ReceivedTime -ne $currentDate)
        {
            Write-Output $_.ReceivedTime
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您无法使用Azure PowerShell完成此任务。

原因:Azure PowerShell旨在从命令行管理和管理Azure资源,以及用于构建针对Azure资源管理器的自动化脚本。

有关详细信息,请参阅“Overview of Azure PowerShell”。