Search code examples
office365exchangewebservicesoutlook-addinoffice-js

Is it possible to fetch mail from subfolder inside Inbox using EWS in c#


I get this error "ErrorInvalidIdMalformed" when i try to fetch mimecontent of a mail from a subfolder inside Inbox. I use the below EWS soap request to get mimecontent.

`

<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""
xmlns:t=""http://schemas.microsoft.com/exchange/services/2006/types"">
<soap:Header>
<t:RequestServerVersion Version=""Exchange2013"" />
</soap:Header>
  <soap:Body>
    <GetItem
      xmlns=""http://schemas.microsoft.com/exchange/services/2006/messages""
      xmlns:t=""http://schemas.microsoft.com/exchange/services/2006/types"">
      <ItemShape>
        <t:BaseShape>Default</t:BaseShape>
        <t:IncludeMimeContent>true</t:IncludeMimeContent>
      </ItemShape>
      <ItemIds>
        <t:ItemId Id = ""{0}""/>
      </ItemIds>
    </GetItem>
  </soap:Body>
</soap:Envelope>"

`

Question: How can I get mimecontent of a mail which is in a subfolder of inbox? should I have to change soap request and add folder id and then make a request for mail?


Solution

  • The error is telling you that the EWSId your using isn't correct eg

    <t:ItemId Id = ""{0}""/>
    

    So the code you have used to retrieve that Id isn't correct.