无法通过EWS访问委派/模拟的共享邮箱

问题描述 投票:0回答:1

我正在尝试通过EWS使用全局管理员帐户凭据获取邮箱文件夹。我正在使用以下带有视点gem的ruby脚本来完成它。

require 'viewpoint'

include Viewpoint::EWS

endpoint = 'https://outlook.office365.com/ews/exchange.asmx'
admin_email = '[email protected]'
password = 'password'

user_email = "[email protected]"

cli = Viewpoint::EWSClient.new endpoint, admin_email, password
cli.set_impersonation 'PrimarySmtpAddress', user_email  #impersonation
act_as_hash = { act_as: user_email }
results = cli.folders(act_as_hash)

puts results.count

我已为所有邮箱创建了所需的权限和模拟。访问共享邮箱时遇到问题。我可以使用相同的脚本访问用户邮箱文件夹。

当我尝试上面的脚本来获取共享邮箱文件夹时,我收到以下错误。

/Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/connection.rb:121:in `check_response': SOAP Error: Message: The primary SMTP address must be specified when referencing a mailbox.  Code: a:ErrorNonPrimarySmtpAddress (Viewpoint::EWS::Errors::SoapResponseError)
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/connection.rb:103:in `post'
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/connection.rb:81:in `dispatch'
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/soap/exchange_web_service.rb:212:in `do_soap_request'
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/soap/exchange_data_services.rb:503:in `find_folder'
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/folder_accessors.rb:45:in `folders'
    from o365_test_connection.rb:14:in `<main>'

我试图评论模拟行并使用委托来访问邮箱文件夹但我收到以下错误。

/Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/folder_accessors.rb:167:in `find_folders_parser': Could not retrieve folders. ErrorNonExistentMailbox: No mailbox with such guid. (Viewpoint::EWS::EwsFolderNotFound)
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/folder_accessors.rb:46:in `folders'
    from o365_test_connection.rb:14:in `<main>'

谁可以帮我这个事?

ruby office365 exchangewebservices impersonation viewpoint
1个回答
0
投票

终于找到了这个错误的根本原因。通常,共享邮箱不需要任何许可证。当我们要访问未经许可的邮箱时,会发生Could not retrieve folders. ErrorNonExistentMailbox: No mailbox with such guiderror。

当我尝试UserPrincipalName而不是PrimarySmtpAddress时,我能够访问邮箱。

© www.soinside.com 2019 - 2024. All rights reserved.