【问题标题】:Access the voting buttons extended property through Exchange Web Services通过 Exchange Web 服务访问投票按钮扩展属性
【发布时间】:2010-11-04 23:53:22
【问题描述】:

我正在使用 Exchange Web 服务 (Exchange server 2007) 尝试发送带有投票按钮的电子邮件。

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

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

然后我使用 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 始终为 false,propertyValue 始终为空。

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

另外,foundItem.ExtendedProperties 的计数始终为零。这个属性里应该没有东西吧?

【问题讨论】:

    标签: c# .net-4.0 exchangewebservices


    【解决方案1】:

    我在这里找到了我需要的信息:
    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())
    

    希望这对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 2017-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-25
      • 2022-01-01
      • 1970-01-01
      • 2021-06-22
      相关资源
      最近更新 更多