简体   繁体   English

有没有一种方法可以使用ews c#确定电子邮件是否为回复/响应?

[英]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. 我正在编写一个支持系统,这是我第一次使用EWS。 Thus far I have been quite successful with it. 到目前为止,我已经非常成功了。 I can extract the info I need. 我可以提取所需的信息。 Send emaisl and everything is working great. 发送emaisl,一切正常。 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);
            }

        }

InReplyTo is a string value that contains the identifier of the item to which this message is a reply. InReplyTo是一个字符串值,其中包含此消息将作为回复的项目的标识符。 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 更多信息: MSDN InReplyTo

Ok. 好。 So from the Comments. 所以从评论。 It seems that There is not really a definitive way. 似乎并没有确定的方法。 People's comments helped me get this answer and to close this thread. 人们的评论帮助我得到了这个答案并结束了这个话题。 I will reword and post it here. 我会改写并张贴在这里。 So first. 所以首先。 Thanks for all your answers. 感谢您的所有答复。

The most simple way is to include a good reference number in your subject. 最简单的方法是在您的主题中包含一个良好的参考号。 Such as "Supp-1234" 例如“ Supp-1234”

Now in code we can check for that reference number in the heading. 现在,在代码中,我们可以在标题中检查该参考号。 If it is there. 如果有的话。 It is most likely a response. 这很可能是一种回应。 Checking for RE is also an option, but somewhat less effective. 也可以选择检查RE,但效果不佳。 The bummer is that clients can remove the reference number/RE from the subject heading. 令人讨厌的是,客户可以从主题标题中删除参考号/ RE。 For those guys. 对于那些家伙。 Poor you, your issue won't get logged. 可怜的你,你的问题不会被记录。 or you know. 或者你知道。 do whatever. 做任何事情。 :) :)

Thanks again to all responses. 再次感谢所有回复。 You guys really helped me a lot ! 你们真的对我有很大帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM