2010-11-04 44 views
1

我使用的Exchange Web服務(Exchange服務器2007)嘗試用投票按鈕在一封電子郵件通過訪問Exchange Web服務的投票按鈕擴展屬性

我看了這個提問/回答:
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永遠是假的,propertyValue始終保持爲空。

當我把一個斷點,並期待在foundItem屬性是正確的其餘部分 - 例如發件人,主題行,發送日期/時間等

另外foundItem.ExtendedProperties始終具有零計數。這個屬性裏有什麼東西嗎?

回答

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()) 

希望這有助於人。