如何从outlook exchange server(EWS)获取约会正文文本,c#
本文关键字:约会 获取 正文 文本 EWS outlook exchange server | 更新日期: 2023-09-27 18:12:54
我正试图从交换服务器获取电子邮件正文,以获得特定房间的约会,但没有成功。在网上核实了所有的博客,但没有任何帮助。以下是我试图联系交换服务器以获取详细信息的代码:
<标题>方法service.GetUserAvailability
(
attendees,
new TimeWindow(twStart, twEnd),
AvailabilityData.FreeBusy
).AttendeesAvailability[0].CalendarEvents;
<标题>方法B public class MailItem
{
public string From;
public string[] Recipients;
public string Subject;
public string Body;
}
public static MailItem[] GetUnreadMailFromInbox(ExchangeService service, string address)
{
// Address is the email address for an meeting room
try
{
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, address);
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));
FindItemsResults<Item> findResults2 = service.FindItems(WellKnownFolderName.Calendar, new ItemView(128));
ServiceResponseCollection<GetItemResponse> items2 =
service.BindToItems(findResults2.Select(item2 => item2.Id), new PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.From, EmailMessageSchema.ToRecipients));
return items.Select(item =>
{
return new MailItem()
{
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();
}
catch (Exception ex)
{
throw ex;
}
}
我需要一个从exchange服务器获取约会主体内容的解决方案。
标题>标题>假设您已经成功连接到Exchange服务,并且只尝试检索约会主体部分,请尝试此操作。
尝试添加EmailMessageSchema.Body
到您的属性集。
service.BindToItems(findResults2.Select(item2 => item2.Id), new PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.From, EmailMessageSchema.Body, EmailMessageSchema.ToRecipients));