Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6 from chakradhar2/fixing_ConverstionGuidIssue
Browse files Browse the repository at this point in the history
Fixing converstion guid issue
  • Loading branch information
codito committed Oct 25, 2017
2 parents 6ac5ebf + 1d7addb commit 6e4cd41
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions src/Supa.Platform/ExchangeServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Supa.Platform
using Microsoft.Exchange.WebServices.Data;

using Serilog;
using System.Collections.ObjectModel;

/// <inheritdoc/>
public class ExchangeServiceProvider : IExchangeServiceProvider
Expand Down Expand Up @@ -99,9 +100,9 @@ public IEnumerable<MailThread> GetEmailThreads(string folderName)
var thread = new MailThread { Id = conversation.Id.ToString(), Topic = conversation.Topic, };
this.logger.Debug("Created {MailThread}", thread);

this.logger.Verbose("Finding emails contained in the thread.");
this.logger.Verbose(string.Format("Finding emails contained in the thread. Topic: {0} ", conversation.Topic));
this.watch.Restart();
var items = GetConversationItemsSingleConversation(exchangeService, folder.Id, conversation.Id);
var items = GetConversationItemsSingleConversation(exchangeService, folder.Id, conversation);
this.watch.Stop();
this.logger.Debug("Time taken to find emails in {thread} = {ElapsedTime}", thread, this.watch.Elapsed);

Expand Down Expand Up @@ -191,32 +192,16 @@ public void DeleteMailFolder(MailFolder mailFolder)
folder.Delete(DeleteMode.HardDelete);
}

private static IEnumerable<Item> GetConversationItemsSingleConversation(ExchangeService service, FolderId folderId, ConversationId conversationId)
private static IEnumerable<Item> GetConversationItemsSingleConversation(ExchangeService service, FolderId folderId, Conversation conversation)
{
var conversationIdProperty = new ExtendedPropertyDefinition(0x3013, MapiPropertyType.Binary);
var cidBinary = Convert.FromBase64String(conversationId.UniqueId);
var cidGuid = new byte[16];
Array.Copy(cidBinary, 43, cidGuid, 0, 16);

var conversationIdValue = Convert.ToBase64String(cidGuid);
var itempropertyset = new PropertySet(BasePropertySet.FirstClassProperties)
{
RequestedBodyType = BodyType.Text
};
var itemview = new ItemView(100) { PropertySet = itempropertyset };

// {
// PropertySet = new PropertySet(
// BasePropertySet.IdOnly,
// ItemSchema.DateTimeReceived,
// ItemSchema.LastModifiedName,
// ItemSchema.DisplayTo,
// ItemSchema.DisplayCc,
// ItemSchema.Subject)
// };
var conversationFilter = new SearchFilter.IsEqualTo(conversationIdProperty, conversationIdValue);
var conversationFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.ConversationTopic, conversation.Topic);
var items = service.FindItems(folderId, conversationFilter, itemview);

return items;
}
}
Expand Down

0 comments on commit 6e4cd41

Please sign in to comment.