2

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

我读了这个问题/答案:
发送投票电子邮件

我有一位使用 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始终为假,并且propertyValue始终保持为空。

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

foundItem.ExtendedProperties总是计数为零。这个属性里不应该有东西吗?

4

1 回答 1

4

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

希望这可以帮助某人。

于 2010-11-04T15:53:22.273 回答