We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Email Tracking C# - Office 365 Exchange server

Dear Team,

We have purchased ASPOSE Email Product. We have below requirement. Can you please share the code and help us out.

We have one common Email Id configured on Office 365 Exchange server. This common ID will be always in CC and we need to track the first and last email thread (Turn around time) for each email.

For E.g:

Common Email ID : [Common@test.com](mailto:Common@test.com)

Requester Email Id : [Request@test.com](mailto:Request@test.com)

Replies Email Id : [Replies@test.com](mailto:Replies@test.com)

Requester sends email to Replies email ID and keeps Common Email Id in CC.

Replies Responds email by keeping common email id in CC.

We need to track turn around time between requester email id & Replies email ID.

Thanks in advance.

Hi Kamlakar,


Thank you for contacting Aspose support team.

ExchangeConversation should be used to track such conversations and get all the messages and dates for each conversation separately.

Please give a try to the following sample code and share the feedback with us.

const string mailboxUri = https://outlook.office365.com/ews/exchange.asmx;<o:p></o:p>

const string domain = @"";

const string username = @"username";

const string password = @"password";

NetworkCredential credentials = new NetworkCredential(username, password, domain);

IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);

ExchangeConversation[] conversations = client.FindConversations(client.MailboxInfo.InboxUri);

foreach (var conver in conversations)

{

foreach (var item in conver.ItemIds)

{

MailMessage msg = client.FetchMessage(item);

Console.WriteLine(msg.Date);

}

}

Okay Thanks.


But How to apply filter to get only un read emails and date period.

Also once fetch the conversation, how to mark it as read.

Thanks.

Hi Kamlakar,


We cannot filter unread emails from a conversation however you can get count of un-read emails in a conversation before processing it.

Once a conversation is processed, you can mark it as read using IEWSClient.SetConversationReadState() function as shown in the following sample code.

const string mailboxUri = https://outlook.office365.com/ews/exchange.asmx;<o:p></o:p>

const string domain = @"";

const string username = @"user@xyz.onmicrosoft.com";

const string password = @"password";

NetworkCredential credentials = new NetworkCredential(username, password, domain);

IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);

ExchangeConversation[] conversations = client.FindConversations(client.MailboxInfo.InboxUri);

foreach (var conver in conversations)

{

//Check count of un-read mails in conversation

if (conver.UnreadCount > 0)

{

foreach (var item in conver.ItemIds)

{

MailMessage msg = client.FetchMessage(item);

Console.WriteLine(msg.Date);

}

//Mark the conversation as read

client.SetConversationReadState(conver.ConversationId, true);

}

}