none
Retrieving email using ews RRS feed

  • Question

  • Hello All,

    I am trying to retrieve the mails from exchange using ews. However, my issue is; my each conversation of one mail is getting treated as different mail. I am displaying the mails in grid view. So, each conversation of single mail is shown on different row; instead it should show on single row with latest reply/conversation. 

    Because of this I am not able to use offset property to retrieve emails.

    My aim is all of the conversation in single mail should be treated as one mail; So If I set the offset property then it should easily give me the mail from that point.

    Below is my code

    public void RetriveEMails()
            {
                String Subject;
                String Sender;
                String EmailBody;
                String[] Recipients;
                Boolean blnHasAttachments;
                int pagesize = 10;
                int offset = 0;
                Boolean more = true;
                String EmailDateTimeReceived;
                String EmailItemID;
                String EmailDisplayTo;
    
    
                ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
                service.Credentials = new NetworkCredential("my id", "my password");
                service.PreAuthenticate = true;
                service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
                service.TraceEnabled = true;
                service.TraceFlags = TraceFlags.All;
    
                ItemView view = new ItemView(pagesize, offset, OffsetBasePoint.Beginning);
    
                FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, view);
    
                view.PropertySet = new PropertySet(
                   BasePropertySet.IdOnly, ItemSchema.Subject, ItemSchema.DateTimeReceived, ItemSchema.DisplayTo,
                   EmailMessageSchema.ToRecipients, EmailMessageSchema.From, EmailMessageSchema.IsRead, EmailMessageSchema.HasAttachments,
                   ItemSchema.MimeContent, EmailMessageSchema.Body, EmailMessageSchema.Sender, ItemSchema.Body) { RequestedBodyType = BodyType.HTML };
    
                view.Traversal = ItemTraversal.Shallow;
                service.LoadPropertiesForItems(findResults, view.PropertySet);
    
                foreach (EmailMessage email in findResults)
                {
                    Sender = email.From.Address;
                    Subject = email.Subject;
                    EmailDateTimeReceived = email.DateTimeReceived.ToShortDateString();
                    blnHasAttachments = email.HasAttachments;
                    EmailItemID = Convert.ToString(email.Id);
                    EmailDisplayTo = email.DisplayTo;
                    EmailBody = email.Body; //.Text;
                    //string[] Recipients = email.ToRecipients;
                }
    
            }

    Any help on this appreciated !

    Regards,

    Rohit


    Thursday, January 22, 2015 11:30 AM

All replies