編輯#的機身2 ---- 它編譯罰款,但我得到的調試錯誤: 上ExchangeService URL屬性必須在該行 設置開啓代碼 這條線'FindItemsResults findResults = service.FindItems(WellKnownFolderName.Inbox,new ItemView(128));'' End EDIT#2 ----C#來捕獲Outlook電子郵件
編輯--- 呃 - 我沒有意識到我需要10個重點發布圖片...讓我給出一些錯誤。
1) Type or namespace 'FindItemsResults' could not be found
2) Type or namespace name 'Item' could not be found
3) The name 'service' does not exist in the current context
4) Type or namespace 'ItemView' could not be found
編輯----
我看到了張貼在這裏 - How to get email body, receipt, sender and CC info using EWS?,並期待在此採碼
public class MailItem
{
public string From;
public string[] Recipients;
public string Subject;
public string Body;
}
public MailItem[] GetUnreadMailFromInbox()
{
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(128));
ServiceResponseCollection<GetItemResponse> items =
service.BindToItems(findResults.Select(item => item.Id), new PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.From, EmailMessageSchema.ToRecipients));
return items.Select(item =>
{
return new MailItem()
{
From = ((Microsoft.Exchange.WebServices.Data.EmailAddress)item.Item[EmailMessageSchema.From]).Address,
Recipients = ((Microsoft.Exchange.WebServices.Data.EmailAddressCollection)item.Item[EmailMessageSchema.ToRecipients]).Select(recipient => recipient.Address).ToArray(),
Subject = item.Item.Subject,
Body = item.Item.Body.ToString(),
};
}).ToArray();
}
但我越來越多編譯錯誤。如何使用C#閱讀電子郵件的正文非常明確的說明方式?
發佈你的錯誤,在這裏沒有人能讀心術所以沒有這些信息,我們不能幫你。 – Sorceri
將一些錯誤添加到原始文章中。對不起,我沒有意識到發佈圖片需要10個重點。我認爲這是我的原始帖子。 – user2676140
我認爲它應該是'FindItems'而不是'findItems' – Icemanind