Tag: exchangewebservices

Exchange Web Services 2010入门

我的任务是在.Net中编写一个SOAP Web服务,作为EWS2010和之前使用WebDAV连接到Exchange的应用服务器之间的中间件。 ( 据我所知,WebDAV正在消失EWS2010,因此应用服务器将无法再像以前那样连接,并且在没有WebDAV的情况下连接到EWS的指数更难。理论上就是在.Net中实现它。应该比其他任何事情都容易……对吧?! ) 我的最终目标是能够获取和更新指定Exchange帐户的电子邮件,日历项目,联系人和待办事项列表项。 (删除目前不是必需的,但我可以将其构建以供将来考虑,如果它很容易的话)。 我最初得到了一些示例代码,实际上确实有效,但我很快意识到它已经过时了。 使用的类型和类在当前文档中没有出现。 例如,用于创建与Exchange服务器的连接的方法是: ExchangeService svc = new ExchangeService(); svc.Credentials = new WebCredentials(AuthEmailAddress, AuthEmailPassword); svc.AutodiscoverUrl(AutoDiscoverEmailAddress); 对于它的价值,这是使用示例代码附带的程序集: Microsoft.Exchange.WebServices.dll (“MEWS”)。 在我意识到这不是当前实现连接的标准方法之前,它起作用了,我尝试在它上面构建并添加一个创建日历项的方法,我从这里复制了 : static void CreateAppointment(ExchangeServiceBinding esb) { // Create the appointment. CalendarItemType appointment = new CalendarItemType(); … } 马上,我遇到了ExchangeService和ExchangeServiceBinding (“ESB”)之间的区别; 所以我开始谷歌搜索试图找出如何获得ESB定义,以便CreateAppointment方法将编译。 我发现这篇博文解释了如何从WSDL生成代理类,我做了。 不幸的是,这导致了一些冲突,其中原始程序集中定义的类型, Microsoft.Exchange.WebServices.dll (示例代码附带)与我的新EWS.dll程序EWS.dll类型重叠(我从生成的代码编译Exchange服务器提供的services.wsdl )。 我排除了MEWSassembly,这只会让事情变得更糟。 我从一些错误和警告转到了25个错误和2,510个警告。 没有找到各种类型和方法。 这里显然有些不对劲。 所以我回去追捕。 […]

使用EWS和Exchange 2007通过对话实现Outlook 2010的组

我们正在使用EWS在我们的某些邮箱上生成一些分析。 部分原因是获得对话的计数/名称/开始/结束。 对话类似于Outlook 2010在按对话分组时显示的方式。 我希望能够使用ConversationId对项目进行分组,但这似乎只是Exchange 2010的一项function。 我可以按文件夹中的主题进行分组以获得线程的简单概念…但是这不会处理拆分对话,因为Outlook 2010会这样做 – 具体而言,它不会处理引入已发送项目中的回复(这些对我们来说很重要 – 如果不看回复,我们就无法获得好的指标。 我目前获取线程信息的代码如下所示: private IEnumerable GetThreads(Folder folder) { var view = new ItemView(int.MaxValue) {PropertySet = new PropertySet(BasePropertySet.IdOnly)}; // view.PropertySet.Add(ItemSchema.ConversationId); – Can’t use this as we’re stuck on Exchange 2007 !!! view.PropertySet.Add(ItemSchema.Subject); view.PropertySet.Add(ItemSchema.DateTimeReceived); var grouping = new Grouping(ItemSchema.Subject, SortDirection.Descending, ItemSchema.DateTimeReceived, AggregateType.Maximum); var groupResults = folder.FindItems(view, grouping); […]

所有文件夹中的Exchange Web服务(EWS)FindItems

我使用以下代码查找用户发送的所有电子邮件,但这只搜索主收件箱文件夹,不检查任何子文件夹。 我想搜索所有邮件项目,包括任何子文件夹。 我尝试过WellKnownFolderName.Root和WellKnownFolderName.Inbox,这些只搜索那些文件夹,而不是子文件夹。 private static void SearchItems(string email) { ItemView iv = new ItemView(10); FindItemsResults fiitems = _service.FindItems(WellKnownFolderName.Inbox, “from:username@example.com”, iv); foreach (Item item in fiitems) { Console.WriteLine(“Subject:\t” + item.Subject); Console.WriteLine(“Received At:\t\t” + item.DateTimeReceived.ToString(“dd MMMM yyyy”)); Console.WriteLine(); } Console.WriteLine(“Press Enter to continue”); Console.ReadLine(); }

从Exchange Web服务托管API获取收件箱中的所有邮件,并将其存储为.eml文件

我想使用EWS托管API获取收件箱文件夹中的所有邮件,并将它们存储为.eml 。 问题在于获取(1)所有邮件(2)所有标题(如from,to,subject) (我在其他地方保留from , to和其他属性的值的信息,所以我也需要它们)和(3)byte[] EmailMessage.MimeContent.Content 。 其实我对此缺乏了解 Microsoft.Exchange.WebServices.Data.ItemView , Microsoft.Exchange.WebServices.Data.BasePropertySet和 Microsoft.Exchange.WebServices.Data.ItemSchema 这就是为什么我发现它很难。 我的主要代码是: 当我按如下方式创建PropertySet : PropertySet properties = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent); 我得到以下exception: The property MimeContent can’t be used in FindItem requests. 我不明白 (1)这些ItemSchema和BasePropertySet是什么 (2)我们应该如何使用它们 所以我删除了ItemSchema.MimeContent : PropertySet properties = new PropertySet(BasePropertySet.FirstClassProperties); 我编写了简单的以下代码来获取收件箱中的所有邮件: ItemView view = new ItemView(50); view.PropertySet = properties; FindItemsResults findResults; List […]

使用C#中的Exchange Web服务托管API检索错误的邮箱项目

我正在尝试使用Exchange Web服务托管API从特定邮箱(我有权限)中检索收件箱项目。 我首先使用我自己的电子邮件地址通过AutodiscoverUrl测试了代码,它运行正常。 但是,当我尝试使用其他电子邮件地址时,EWS仍会检索我自己的收件箱项目。 这是由于缓存还是什么? 我的代码如下: ExchangeService ex = new ExchangeService(ExchangeVersion.Exchange2010_SP1); ex.AutodiscoverUrl(“someothermailbox@company.com”); FindItemsResults findResults = ex.FindItems(WellKnownFolderName.Inbox, new ItemView(10)); foreach (Item item in findResults.Items) Console.WriteLine(item.Subject);

如何从Exchange Server获取联系人列表?

谁能告诉我从Exchange Server获取联系人列表的最简单方法? 我正在使用C# 根据我的发现, Exchange Web服务仅适用于Exchange Server 2007及更高版本。 这将是我的第一个选择,但我也喜欢以前版本的Exchange(WebDav或其他)的替代品。 目录服务不是一种选择。

使用EWS托管APIvalidation登录凭据

有没有办法validation用户使用EWS托管API提供的登录凭据而不发送电子邮件。 我在[ExchangeService]对象上使用AutodiscoverUrl方法,但它需要太长时间? 任何建议都会很感激。 try { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1); service.Credentials = new WebCredentials(“xxxx@yyy.com”, “password”); service.AutodiscoverUrl(“xxxx@yyy.com”, RedirectionUrlValidationCallback); Console.WriteLine(“Credentials validated successfully”); Console.ReadLine(); } catch(Exception e) { Console.WriteLine(e.Message); Console.ReadLine(); }

交换Web服务:为什么ItemId不是常量?

正如其他一些人之前已经讨论过这个问题(例如, Exchange Web服务:为什么ItemId不是常数? ),我想谈谈解决方案,我已经通过将Guid标记为扩展属性来完成了人们所建议的内容,对我而言解决方案有点好(虽然我不知道如何使它与出现的一起工作)但只要应用程序正常工作,一旦应用程序重新启动项目的扩展属性消失,所以我现在的问题是“ 如何在EWS项目上标记扩展属性并使其不断存在? “这是更新日历项目(约会)的代码 public void SetGuidForAppointement(Appointment appointment) { appointment.SetExtendedProperty((ExtendedPropertyDefinition)_appointementIdPropertyDefinition, Guid.NewGuid().ToString()); appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone); } 这些是上面需要的属性定义。 _appointementIdPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Appointment, “AppointmentID”, MapiPropertyType.String); _propertyDefinitionBases = new PropertyDefinitionBase[] { _appointementIdPropertyDefinition, ItemSchema.ParentFolderId, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.LegacyFreeBusyStatus, AppointmentSchema.Organizer }; PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, _propertyDefinitionBases); 因此,如果有人之前已经这样做了,他/她可以提供一个示例,即使应用程序退出,也会将扩展属性标记在项目上。 谢谢

如何使用EWS托管API从PublicFolders的文件夹和子文件夹中获取所有ITEMS

如何从Exchange Server2010 uisng托管API中的“公共文件夹”及其“子文件夹”中检索所有项目??? rootfolder = Folder.Bind(service,WellKnownFolderName.PublicFoldersRoot); rootfolder.Load(); foreach (Folder folder in rootfolder.FindFolders(new FolderView(int.MaxValue))) { FindItemsResults findResults = folder.FindItems(iv); foreach (Item item in findResults) { //get item info; } } “如果我这样做,我不会在它的子文件夹中存在项目..公共文件夹也不支持深度遍历查询..如何从公用文件夹的子文件夹中获取项目???”

通过EWS API连接到Office 365

我在我的控制台应用程序中使用EWS API来处理邮箱项目,我的连接脚本看起来像 ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.UseDefaultCredentials = true; service.AutodiscoverUrl(“emailService@domain.com”); 但我发现我的电子邮件帐户已移至Office 365云。 我该如何更改身份validation? 我找到了EWS服务url service.Url = new Uri(“https://outlook.office365.com/EWS/Exchange.asmx”); 但我不知道如何使用它。 谢谢