我正在使用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
始终为null。
当我设置断点并查看foundItem
时,其余属性是正确的 - 例如发件人,主题行,发送日期/时间等
此外foundItem.ExtendedProperties
的计数始终为零。该房产中没有什么东西?
答案 0 :(得分:2)
我在这里找到了我需要的信息:
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())
希望这有助于某人。