代码之家  ›  专栏  ›  技术社区  ›  bgs264

通过Exchange Web服务访问投票按钮扩展属性

  •  1
  • bgs264  · 技术社区  · 15 年前

    我读到这个问题/答案:
    Send Voting Email

    我有一位同事使用Outlook 2007向我发送了一封带有简单的“是/否”投票按钮的电子邮件(outlook2007中显示的按钮,我没有发送答案),我可以确认这是我收件箱中的第一封电子邮件。

    然后,我使用EWS获取该电子邮件,并尝试获取与该电子邮件相关的扩展属性,这样我就可以获取与投票按钮相关的二进制文件,从而使用投票按钮发送我自己的电子邮件。

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
    
    service.Url = new Uri(ConfigurationManager.AppSettings["URL"]);
    
    service.Credentials = new NetworkCredential(
        ConfigurationManager.AppSettings["Username"], 
        ConfigurationManager.AppSettings["Password"], 
        ConfigurationManager.AppSettings["Domain"]
        );
    
    
    Item foundItem = service.FindItems(WellKnownFolderName.Inbox, new ItemView(10)).Items[0];
    
    ExtendedPropertyDefinition epd = new ExtendedPropertyDefinition(
        DefaultExtendedPropertySet.Common,
        0x00008520,
        MapiPropertyType.Binary
    );
    
    object propertyValue = null;
    
    bool outBool;
    
    outBool = foundItem.TryGetProperty(epd, out propertyValue);
    

    outBool 总是假的,而且 propertyValue 始终保持为空。

    当我设置断点并查看 foundItem 其他属性正确-例如发件人、主题行、发送日期/时间等。

    阿尔索 foundItem.ExtendedProperties 总是计数为零。这地方不应该有什么东西吗?

    1 回复  |  直到 9 年前
        1
  •  2
  •   bgs264    15 年前

    我在这里找到了我需要的信息:
    http://social.technet.microsoft.com/Forums/en/exchangesvrdevelopment/thread/2dbab0f2-b23f-4808-8f55-9ecc77edf877

    C类#

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
    
    service.Url = new Uri(ConfigurationManager.AppSettings["URL"]);
    
    service.Credentials = new NetworkCredential(
        ConfigurationManager.AppSettings["Username"], 
        ConfigurationManager.AppSettings["Password"], 
        ConfigurationManager.AppSettings["Domain"]
        );
    
    Item foundItem = service.FindItems(WellKnownFolderName.Inbox, new ItemView(10)).Items[0];
    
    ExtendedPropertyDefinition myProp = new ExtendedPropertyDefinition(
        DefaultExtendedPropertySet.Common,
        0x00008520,
        MapiPropertyType.Binary
    );
    
    EmailMessage otherMessage = EmailMessage.Bind(service, foundItem.Id, new PropertySet(myProp));
    byte[] bytes = (byte[])otherMessage[myProp];   
    

    VB语言

    Dim service As New ExchangeService(ExchangeVersion.Exchange2007_SP1)
    service.Url = New Uri(ConfigurationManager.AppSettings("URL"))
    service.Credentials = New NetworkCredential(ConfigurationManager.AppSettings("Username"), ConfigurationManager.AppSettings("Password"), ConfigurationManager.AppSettings("Domain"))
    
    Dim myProp As New ExtendedPropertyDefinition(
       DefaultExtendedPropertySet.Common,
       34080,
       MapiPropertyType.Binary
    )
    
    Dim foundItem As Item = service.FindItems(WellKnownFolderName.Inbox, New ItemView(10))(0)
    
    Dim otherMessage As EmailMessage = EmailMessage.Bind(service, foundItem.Id, New PropertySet(myProp))
    Dim bytes As Byte() = DirectCast(otherMessage(myProp), Byte())