列出Office 365邮箱中的电子邮件 [英] List emails in an Office 365 mailbox

查看:128
本文介绍了列出Office 365邮箱中的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用此脚本在我的邮箱中收到电子邮件,但是  I 需要在任何邮箱中获取邮件。如何指定邮箱的别名或smtp地址以获取邮箱中的电子邮件。 (我是管理员,已经可以访问所有
用户邮箱)

I could use this script to get the emails in my mailbox, But  I  need get the messages in any mailbox. How can i specify the alias or smtp address of the mailbox to get the emails within the mailbox. (I am an Admin and already have access to all user mailboxes)

#Load the API DLL
$dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll"
[void][Reflection.Assembly]::LoadFile($dllpath)

#Create a new service object
$service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1)

$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$sidbind = "LDAP://"
$aceuser = [ADSI]$sidbind
$service.AutodiscoverUrl($aceuser.mail.ToString())

$inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, [Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox)
$viewCount = 60
$view = New-Object Microsoft.Exchange.WebServices.Data.ItemView($viewCount)
$findResults = $service.FindItems([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$view)


$i = 0
#$cpsFound = 0
while ($i -le ($viewCount - 1))
{
$currdate = Get-Date
    #$findResults.Items[$i].Id |fl *
    if($findResults.Items[$i].DateTimeSent.ToShortDateString() -eq $currdate.ToShortDateString())
    {
        if($findResults.Items[$i].Subject.Contains("STRING_UR_LOOKING_4") -eq $True)
        {
         
        "Subject : " + $findResults.Items[$i].Subject

        $EmailItemID = $findResults.Items[$i].Id
        $currEmailItem = [Microsoft.Exchange.WebServices.Data.Item]::Bind($service,$EmailItemID)   
        $currSubject = $findResults.Items[$i].Subject
        $myParseCmd = $currSubject.Split("|")
       
        #$currEmailItem.Sender.Address

        } 
        }    
        
     # Increment the while loop 
        $i +=1
    } 


此脚本取自https://social.technet.microsoft.com/Forums/windowsserver/en-US/2b116f1b-30b7-4d14-8d5e-e4832920ad2d/export-email -header-information-via-powershell。谢谢StrayMuse


This script was taken from https://social.technet.microsoft.com/Forums/windowsserver/en-US/2b116f1b-30b7-4d14-8d5e-e4832920ad2d/export-email-header-information-via-powershell . Thanks StrayMuse

推荐答案

你好hdsouza,

Hi hdsouza,

我' ll将此主题移至
Exchange开发论坛
,如他们应该对此有更多的专业知识,你可以及时得到有效的解决方案。

I'll move this thread to Exchange development forum, as they should have more professional knowledge on this and you may get effective solution timely.

感谢您的理解,


这篇关于列出Office 365邮箱中的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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