【问题标题】:How can I tell if an email message is a reply to another email message using EWS如何使用 EWS 判断一封电子邮件是否是对另一封电子邮件的回复
【发布时间】:2014-09-29 12:01:47
【问题描述】:

我正在使用 EWS 查询邮箱中的电子邮件。我得到了一个电子邮件列表。 我想知道如何判断一封电子邮件是否是对邮箱中较早电子邮件的回复?基本上,我想将电子邮件分组,例如 Outlook 中的“作为对话查看”视图。我怎样才能像这样链接电子邮件?

谢谢。

【问题讨论】:

    标签: exchangewebservices


    【解决方案1】:

    如果您使用 2010 或更高版本,则可以使用 EWS 中的对话操作来执行此操作,请参阅 http://msdn.microsoft.com/en-us/library/office/dn610351(v=exchg.150).aspx

    您可以使用的另一种方法是从扩展属性中获取传输标头并解析出 InReplyTo 标头,例如

            ItemView view = new ItemView(100);
            view.PropertySet = new PropertySet(PropertySet.IdOnly);
            PropertySet PropSet = new PropertySet();
            PropSet.Add(ItemSchema.HasAttachments);
            PropSet.Add(ItemSchema.Body);
            PropSet.Add(ItemSchema.DisplayTo);
            PropSet.Add(ItemSchema.IsDraft);
            PropSet.Add(ItemSchema.DateTimeCreated);
            PropSet.Add(ItemSchema.DateTimeReceived);
            ExtendedPropertyDefinition PR_TRANSPORT_MESSAGE_HEADERS = new ExtendedPropertyDefinition(0x007D, MapiPropertyType.String);
            PropSet.Add(PR_TRANSPORT_MESSAGE_HEADERS);
            FindItemsResults<Item> findResults;
            List<EmailMessage> emails = new List<EmailMessage>();
            do
            {
                findResults = service.FindItems(WellKnownFolderName.Inbox, view);
                if (findResults.Items.Count > 0)
                {
                    service.LoadPropertiesForItems(findResults.Items, PropSet);
                    foreach (var item in findResults.Items)
                    {
                        String Headers = "";
                        if (item.TryGetProperty(PR_TRANSPORT_MESSAGE_HEADERS, out Headers))
                        {
                            Int32 slen = Headers.IndexOf("In-Reply-To:");
                            if (slen > 0)
                            {
                                Int32 elen = Headers.IndexOf("\r\n", (slen + 12));
                                Console.WriteLine("InReponse to : " + Headers.Substring((slen+12),elen-(slen+12)));
                            }
    
                        }                        
                    }
                }
                view.Offset += findResults.Items.Count;
            } while (findResults.MoreAvailable);
    

    干杯 格伦

    【讨论】:

      猜你喜欢
      • 2012-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多