EWS Managed API를 사용하여받은 편지함 및 하위 폴더에서 이메일을 읽습니다. 사서함 소유자로 사용자 이름 & 암호 인증으로 연결하면 정상적으로 작동하지만 Windows 인증을 사용하는 서비스 계정으로 연결할 때 하위 폴더에 액세스 할 때 오류가 발생합니다. 서비스 계정에 연결할 사서함에 대한 모든 권한이 부여되었습니다. 서비스 계정에는 자체 사서함이 없습니다.EWS에서 다른 사용자의 Exchange 사서함에 액세스 할 때 ErrorMissingEmailAddress 오류가 발생했습니다.
Problem encountered while retrieving the email from exchange. Microsoft.Exchange.WebServices.Data.ServiceResponseException: When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids.
at Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary()
at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
at MyMethod_That_Calls_ExchangeServer_FindItems(folderId, view)
이 당신이 (즉, 사용자가 자신의 사서함에 연결되지 않음) 사서함에 대리인 액세스를 사용할 때 얻을 수있는 매우 일반적인 오류이며, 당신은을 지정하지 않고 잘 알려진 사서함에 연결 : 오류입니다 사서함 소유자. 쉽게 해결할 수 있습니다. Mailbox
개체를 연결하려는 사서함의 기본 SMTP 주소와 함께 사용하여 FolderId
개체를 만듭니다.
var theMailboxEmailAddress = "[email protected]";
var folderId = new FolderId(WellKnownFolderName.Inbox,
new Mailbox(theMailboxEmailAddress);
var items = myExchangeService.FindItems(folderId, anItemView);
그러나, 제 경우는 그렇게 쉽지 않습니다. 사서함을 지정할 수 있지만 하위 폴더에 FindItems
을 호출하면 오류가 발생합니다. 하위 폴더에 액세스 할 때 사서함을 지정하는 방법은 없습니다. 하위 폴더없이 작동해야하기 때문입니다.
this article ('명시 적 액세스 및 EWS')에 따르면 제안 된 방법은 다음과 같습니다
- 시작 'explicit access'를 사용하여 다음을 식별 할
MailBox
PARAM을 전달하는DistinguishedFolderId
(일명WellKnownFolderName
)와FindFolder()
를 호출 사서함 소유자. 나를 위해 잘 작동- , 내가받은 편지함 아래에있는 폴더의 목록을 한 후 'implicit access'를 사용하는 폴더를
ItemId
값
- , 내가받은 편지함 아래에있는 폴더의 목록을 한 후 'implicit access'를 사용하는 폴더를
- 을 얻을 수 있어요 :에서 검색 folderId 전달
service.FindItems(folderId, view)
전화 이전 단계. 이것은 나를 위해 실패합니다. 이것은 놀랍습니다.
EWS 추적을 보면 내 FindItems()
요청에 DistinguishedFolderIds가 전송되지 않음을 알 수 있습니다.
Trace type: EwsRequest
Trace message: <Trace Tag="EwsRequest" Tid="13" Time="2016-10-13 12:50:05Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2" />
</soap:Header>
<soap:Body>
<m:FindItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
<t:FieldURI FieldURI="item:DateTimeReceived" />
<t:FieldURI FieldURI="message:IsRead" />
<t:FieldURI FieldURI="message:From" />
<t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="X-MyApp-MailId" PropertyType="String" />
</t:AdditionalProperties>
</m:ItemShape>
<m:IndexedPageItemView MaxEntriesReturned="6" Offset="0" BasePoint="Beginning" />
<m:SortOrder>
<t:FieldOrder Order="Ascending">
<t:FieldURI FieldURI="item:DateTimeReceived" />
</t:FieldOrder>
</m:SortOrder>
<!-- Note below there's no DistinguishedFolderId, so nowhere to specify the mailbox -->
<m:ParentFolderIds>
<t:FolderId Id="AAMkAGU2NWRkNjYxLTI3YjktNDFkMi04ZmNlLWI0M2FmMGVmYzBhYwAuAAAAAAD/Z9M6ia69S5l65fo6tjEaAQAoQBtCK9L9S4ux7hB0Qcw/AAAIZFKVAAA=" />
</m:ParentFolderIds>
</m:FindItem>
</soap:Body>
</soap:Envelope>
</Trace>
여기 실패 응답입니다 : 여기에 실패 호출입니다
Trace type: EwsResponse
Trace message: <Trace Tag="EwsResponse" Tid="13" Time="2016-10-13 12:50:05Z" Version="15.00.0913.015">
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="847" MinorBuildNumber="31" Version="V2_8" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:FindItemResponseMessage ResponseClass="Error">
<m:MessageText>When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids.</m:MessageText>
<m:ResponseCode>ErrorMissingEmailAddress</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
</m:FindItemResponseMessage>
</m:ResponseMessages>
</m:FindItemResponse>
</s:Body>
</s:Envelope>
</Trace>
예에서 나는 ExchangeServerVersion Exchange2010_SP2를 지정되었다 위는 그러나 나는 Exchange2013으로도 시도했습니다. Exchange 2013 서버에 연결하고 있습니다.
동료가 EWSEditor를 사용하여 동일한 작업을 시도했지만 동일한 오류가 발생했습니다. 아직 두 번 확인하지는 않았지만, 그렇다면 API를 사용할 때 발생하는 EWS 문제 또는 쉬운 실수를 암시합니다.
또한 MSDN 포럼 here에 게시되었습니다.
UPDATE (13) - 10 월 16 일 :은 Exchange의 '디자인에 의해'제한하는 경우 지금 궁금하네요이 Handling delegation-related errors in EWS in Exchange 기사에 기반
. 즉받은 편지함의 잘 알려지지 않은 폴더를보고 싶다면 사서함이 있어야하며 그렇지 않으면 사용 권한이나 그와 비슷한 것을 관리 할 수 없습니다. 이 문서에서는 ErrorMissingEmailAddress
에 대해 "사서함이없는 대리인 계정을 사용하여 요청하기"라고 말합니다. "대리인의 계정에 사서함 추가"를 통해 처리 할 수 있습니다.
서비스 계정에 사서함을 추가하면 (전혀 사용되지 않음) 문제가 해결되는지 내일 확인하겠습니다.
이 서비스는 읽는 것이 몇 가지 빠른 테스트 코드에서 내 결과는 귀하의 교환 편지함 또는 모든 사람들이 그것입니다 모두가 왜 그게 작동하지 않는지 생각하고 있어요. 아주 명백합니다. 생각하지 않으세요 ..? – MethodMan
@MethodMan - 사용 권한 문제 일 수 있다고 언급하고 있습니까? 아니요, '내'사서함이 아니지만 서비스 계정에 대한 사용 권한이 있으므로받은 편지함에서 폴더를 읽는 데 적합합니다. 서비스 계정에는 읽으려고하는 사서함에 대한 모든 권한이 있습니다. 나는 정말 쉽게 이해할 수있는 뭔가가 있기를 바란다. – Rory