Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to determine if a email is a reply/response using ews c#?

I am writing a support system and this is my first time using EWS. Thus far I have been quite successful with it. I can extract the info I need. Send emaisl and everything is working great. I do have one small headache. Is there a way to tell if an email is in fact a reply ? The basic idea of the app is someone sends an email. We reply and give them a reference number. This is done and working great. Now if they reply to this same address, we need to log it a bit different in our database. thus I need some magical way to tell if the email is a reply. Thus far I am stuck.

Any suggestions will be greatly appreciated as I am new in the programming industry and thus far googling turned up nothing useful. I include a section of code here

 FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, view);

        foreach (Item myItem in findResults.Items.Where(i => i is EmailMessage))
        {
            var mailItem = myItem as EmailMessage;
            if (!mailItem.IsRead)
            {
                // load primary properties and get a text body type
                mailItem.Load(propertySet);
                // Update the item to isRead in email
                mailItem.IsRead = true;
                mailItem.Update(ConflictResolutionMode.AutoResolve);

                //Check if it is a reply and mark the msg as such

                // add message to list
                SupportEmailMessage msg = new SupportEmailMessage();
                msg.Subject = mailItem.Subject;
                msg.MessageBody = mailItem.Body.Text;
                msg.DateSent = mailItem.DateTimeSent;
                msg.Sender = mailItem.Sender.Address;
                toReturnList.Add(msg);
            }

        }
like image 550
KapteinMarshall Avatar asked Jul 25 '13 09:07

KapteinMarshall


1 Answers

InReplyTo is a string value that contains the identifier of the item to which this message is a reply. If it's null, then the message is not a reply.

var mailItem = myItem as EmailMessage;
if (mailItem.InReplyTo != null)
{
   // this is a reply message
   .
   .
   .
}

Further info: MSDN InReplyTo

like image 114
jim31415 Avatar answered Sep 28 '22 15:09

jim31415