EWS send mail meeting, read meeting message(一)

最近做了一个项目,负责的主要模块,是web系统跟 OutLook 数据相互同步,就是从web发送邮件,会议邀请到 OutLook,然后把OutLook客户端发送的Meeting同步到web系统中

首先是读取OutLook

1 用有权限的账号登陆EWS服务 读取指定邮箱 的Meeting。这个账号是一个权限比较大的账号,可以模拟别的邮箱,读取被模拟邮箱的邮件,如果是普通用户邮箱,要读取自己的邮件信息,只需要开通访问EWS服务的权限。

  1  static void TestEws()
  2         {
  3             try
  4             {
  5                 ExchangeService service = new ExchangeService();
  6                 service.Credentials = new WebCredentials(WebConfig.GetString("Usercount"), WebConfig.GetString("pwd"));//有访问EWS 权限的账号 密码
  7                 service.Url = new Uri(WebConfig.GetString("ExchangeUrl"));//已知EWS URL
  8
  9                 var folderView = new FolderView(1000)
 10                 {
 11                     Traversal = FolderTraversal.Deep,
 12                     PropertySet = new PropertySet(FolderSchema.FolderClass,
 13                        FolderSchema.DisplayName,
 14                        FolderSchema.TotalCount,
 15                        FolderSchema.ArchiveTag,
 16                        FolderSchema.ManagedFolderInformation,
 17                        FolderSchema.ParentFolderId)
 18                 };
 19
 20                 service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, WebConfig.GetString("calendarEmail"));//模拟邮箱,读取被模拟邮箱的Meeting
 21                 FindFoldersResults folders = service.FindFolders(WellKnownFolderName.MsgFolderRoot, folderView); 22
 23                  var calendarlist = folders.Folders.Where(x => x.DisplayName.ToLower().Trim() == "calendar"); 26
 27
 28                 var CalendarList = new List<Invitation>();
 29                 foreach (Folder myFolder in calendarlist)
 30                 {
 31                     var calendar = (myFolder as CalendarFolder);
 32                     CalendarView cView = new CalendarView(DateTime.Now, DateTime.Now.AddDays(90), 99999);
 33                     cView.PropertySet = new PropertySet(BasePropertySet.IdOnly);
 34                     FindItemsResults<Appointment> findResults = calendar.FindAppointments(cView);
 35
 36                     if (findResults.TotalCount <= 0)
 37                         continue;
 38                     //load properties, like attendees, textbody and so on
 39                     service.LoadPropertiesForItems(
 40                     (from item in findResults select item).Distinct(),
 41                     new PropertySet(
 42                           BasePropertySet.IdOnly,
 43                                 AppointmentSchema.Subject,
 44                                 AppointmentSchema.Start,
 45                                 AppointmentSchema.ConversationId,
 46                                 AppointmentSchema.End,
 47                                 AppointmentSchema.Organizer,
 48                                 AppointmentSchema.TextBody,
 49                                 AppointmentSchema.RequiredAttendees,
 50                                 AppointmentSchema.AppointmentState,
 51                                 AppointmentSchema.AppointmentType,
 52                                 AppointmentSchema.Location,
 53                                 AppointmentSchema.LastModifiedTime,
 54                                 AppointmentSchema.Body,
 55                                 AppointmentSchema.ICalUid
 56                     ));
 57
 58                     int count = 0;
 59                     var itemlist = new List<string>();
 60                     foreach (Appointment a in findResults)
 61                     {
 62                         if (itemlist.Contains(a.ICalUid))
 63                         {
 64                             continue;
 65                         }
 66                         else
 67                         {
 68                             itemlist.Add(a.ICalUid);
 69                         }
 70
 71                         if (a.Location == null)
 72                         {
 73                             count++;
 74                             break;
 75                         }
 76
 77                         CalendarList.Add(new Invitation()
 78                         {
 79                             OutlookID = a.ICalUid.ToString(),
 80                             Subject = a.Subject.ToString(),
 81                             Organizer = a.Organizer.Address.ToString(),
 82                             Attendees = GetAttendees(a.RequiredAttendees),
 83                             Start = a.Start,
 84                             End = a.End,
 85                             AppointmentState = a.AppointmentState,
 86                             LastModifiedTime = a.LastModifiedTime,
 87                             Location = a.Location.ToString(),
 88                             TextBody = a.Body.ToString()
 89                         });
 90                         count++;
 91
 92                     }
 93
 94                 }
110               121                 Console.Read();
122
123             }
124             catch (Exception ex)
125             {
126                 Console.WriteLine(ex.Message);
135
136             }
137         }      

2.订阅制定邮箱,当该邮箱收到新的有件时,能直接收到EWS的推送信息

订阅分三种方式  EWS拉通知   EWS流式处理通知  推送通知

参考资料

https://msdn.microsoft.com/zh-cn/library/office/dn458791(v=exchg.150).aspx

https://www.cnblogs.com/wolf-sun/p/6483415.html

原文地址:https://www.cnblogs.com/zrynet/p/8656501.html

时间: 2024-11-10 15:20:59

EWS send mail meeting, read meeting message(一)的相关文章

发送邮件的三种方式:Send Mail Message

发送邮件的三种方式: 1.VBS 执行vbs脚本文件的程序为: system32文件下的 NameSpace = "http://schemas.microsoft.com/cdo/configuration/" Set Email = createObject("CDO.Message") Email.From = "xxx" '發送者 Email.To = "xxx;xxx" '收件地址 Email.Subject = &

SSIS Send Mail

在SSIS中Send Mail的方法主要有三种,使用Send Mail Task,使用Script Task和使用存储过程msdb.dbo.sp_send_dbmail. 一,使用Send Mail Task Send Mail Task 是SSIS提供的Task,使用非常简单,但有限制: 只能发送普通的文本格式的邮件,不支持 HTML 格式的邮件. 链接到SMTP Server有两种验证方式,在域中使用 Windows 方式验证,或使用匿名验证. SMTP Server 使用默认的端口号25

How to attach multiple files in the Send Mail Task in SSIS

Let’s say you need to create a SSIS package that creates 2 files and emails the files to someone. Your package may look something like this: Double-click the Send Mail Task to open the Send Mail Task Editor (shown below). Fill in all the relevant fie

IBM supervessel power云平台 之 send mail 篇

声明 : 此文档只做学习交流使用,请勿用作其他商业用途 author : 朝阳_tony E-mail : [email protected] Create Date: 2015-3-9 22:55:43 Monday Last Change: 2015-3-9 22:55:52 Monday 转载请注明出处:http://blog.csdn.net/linzhaolover 摘要: 朝弟,咱们今天有个新的任务,在你的机器上运行一个测试实例,然后将结果通过mail发送到我的邮箱,方便后期查阅!先

how to send mail from 3rd

http://www.advancedintellect.com/post/2011/03/02/Exchange-2010-and-SMTP-settings.aspx Enviroment: Exchange 2010, 2013 which only have hub role and other roles 1. we should use the followign code to triggle sending mail script: http://www.daixiaorui.c

Python 3.4 send mail

#coding=utf-8 #Python 3.4 https://docs.python.org/3.4/library/ #IDE:Visual Studio 2015 Window10 import atexit import os import unicodedata import sys import time import unicodedata import winsound import code import codecs import math import csv impo

python trojan development 2nd —— use python to send mail and listen to the key board then combine them

今晚先上代码,明天再说怎么写的,请勿用于非法用途!!!!! 1 from pynput.keyboard import Key,Listener 2 import logging 3 import os 4 import smtplib 5 from email.mime.text import MIMEText 6 from PIL import ImageGrab 7 import random 8 from time import * 9 from email.mime.multipart

python send mail

plese find www.baidu.com

login SMTP send mail error : Unable to read data from the transport connection: net_io_connectionclosed

client.Credentials = new NetworkCredential(sSMTPuser, sSMTPpass); client.Credentials = new NetworkCredential([email protected], sSMTPpass); 用户名需要带上域名,真是脑残的邮件服务器: 亿邮.