C# ExChange WES API

1.准备 Microsoft.Exchange.WebServices.dll 和 Microsoft.Exchange.WebServices.Auth.dll

2.调用对应方法

 class Program
    {
        static void Main(string[] args)
        {
            // Validate the server certificate.
            // For a certificate validation code example, see the Validating X509 Certificates topic in the Core Tasks section.

            try
            {
                // Connect to Exchange Web Services as user1 at contoso.com.
                ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
                service.Credentials = new WebCredentials("邮箱@outlook.com", "密码,");
                service.AutodiscoverUrl("han.l@outlook.com");

                // Create the e-mail message, set its properties, and send it to user2@contoso.com, saving a copy to the Sent Items folder. 
                EmailMessage message = new EmailMessage(service);
                message.Subject = "Interesting";
                message.Body = "The proposition has been considered.";
                message.ToRecipients.Add("发送的邮件");

                //发送邮件
                message.Send();
                Console.WriteLine("Message sent!");
                Console.ReadLine();

                Appointment appointment = new Appointment(service);
                appointment.Subject = "Status Meeting";
                appointment.Body = "The purpose of this meeting is to discuss status.";
                appointment.Start = new DateTime(2017, 12, 27, 16, 0, 0); //年月日 时分秒
                appointment.End = appointment.Start.AddHours(2);
                appointment.Location = "Conf Room";
                appointment.RequiredAttendees.Add("发送的邮件1");
                appointment.RequiredAttendees.Add("发送的邮件2");
                //订会议
                appointment.Save(SendInvitationsMode.SendOnlyToAll);


                // 查询对应日程
                DateTime startDate = DateTime.Now.AddDays(-1);
                DateTime endDate = startDate.AddDays(30);
                const int NUM_APPTS = 5;

                // Initialize the calendar folder object with only the folder ID. 
                CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());

                // Set the start and end time and number of appointments to retrieve.
                CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);

                // Limit the properties returned to the appointment's subject, start time, and end time.
                cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);

                // Retrieve a collection of appointments by using the calendar view.
                FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);

                Console.WriteLine("\nThe first " + NUM_APPTS + " appointments on your calendar from " + startDate.Date.ToShortDateString() +
                                  " to " + endDate.Date.ToShortDateString() + " are: \n");

                foreach (Appointment a in appointments)
                {
                    //显示当前有的日程
                    Console.Write("Subject: " + a.Subject.ToString() + " ");
                    Console.Write("Start: " + a.Start.ToString() + " ");
                    Console.Write("End: " + a.End.ToString());
                    Console.WriteLine();
                }


                //拿到用户消息
                 AutodiscoverService autodiscoverService = new AutodiscoverService("outlook.office365.com");
                autodiscoverService.Credentials = new NetworkCredential("han.wang@xunyisoft.com", "liange0819jia,", "outlook.office365.com");

                //提交请求并获取设置。响应只包含所请求的
                //设置,如果它们存在的话。

                GetUserSettingsResponse userresponse = autodiscoverService.GetUserSettings(
                "z@xunyisoft.com",
                UserSettingName.UserDN,
                UserSettingName.UserMSOnline,  //是否在线
                UserSettingName.UserDisplayName, //显示名称
                UserSettingName.InternalEcpVoicemailUrl,
                UserSettingName.InternalEcpEmailSubscriptionsUrl,
                UserSettingName.EcpVoicemailUrlFragment,
                UserSettingName.EcpEmailSubscriptionsUrlFragment,
                UserSettingName.ExternalEcpVoicemailUrl,
                UserSettingName.ExternalEcpEmailSubscriptionsUrl,
                UserSettingName.AlternateMailboxes,
                UserSettingName.ActiveDirectoryServer,
                UserSettingName.UserDeploymentId,
                UserSettingName.InternalMailboxServer,
                UserSettingName.MailboxDN,
                UserSettingName.PublicFolderServer,
                UserSettingName.ActiveDirectoryServer,
                UserSettingName.ExternalMailboxServer,
                UserSettingName.EcpDeliveryReportUrlFragment,
                UserSettingName.EcpPublishingUrlFragment,
                UserSettingName.EcpTextMessagingUrlFragment,
                UserSettingName.ExternalEwsUrl,
                UserSettingName.CasVersion,
                UserSettingName.EwsSupportedSchemas

               );

                Console.WriteLine(userresponse);
                foreach (KeyValuePair<UserSettingName, Object> usersetting in userresponse.Settings)
                {
                    Console.WriteLine(usersetting.Key.ToString() + ": " + usersetting.Value);
                }



                // Get the number of items in the contacts folder. To limit the size of the response, request only the TotalCount property.
                ContactsFolder contactsfolder = ContactsFolder.Bind(service,
                                                                    WellKnownFolderName.Contacts,
                                                                    new PropertySet(BasePropertySet.FirstClassProperties, FolderSchema.TotalCount));

                // Set the number of items to the number of items in the Contacts folder or 50, whichever is smaller.
                int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50;

                // Instantiate the item view with the number of items to retrieve from the Contacts folder.
                ItemView view = new ItemView(numItems);

                // To keep the response smaller, request only the display name.
                view.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, ContactSchema.DisplayName,
                    ContactSchema.Birthday, 
                    ContactSchema.JobTitle, 
                    ContactSchema.Alias,
                    ContactSchema.AssistantName,
                    //ContactSchema.EmailAddresses,
                    //ContactSchema.PhoneNumbers,
                    ContactSchema.ManagerMailbox); //EmailAddresses  PhoneNumbers 不能在这里加入请求

                // Request the items in the Contacts folder that have the properties that you selected.
                FindItemsResults<Item> contactItems = service.FindItems(WellKnownFolderName.Contacts, view);
                
                foreach (Item item in contactItems)
                {
                    if (item is Contact)
                    {
                        Contact contact = item as Contact;
                        Console.WriteLine(contact.DisplayName);
                        // Console.WriteLine(contact.PhoneNumbers);
                        Console.WriteLine(contact.JobTitle);
                        Console.WriteLine(contact.Alias);
                        Console.WriteLine(contact.AssistantName);
                        Console.WriteLine(contact.ManagerMailbox);
                        NameResolutionCollection nd = service.ResolveName(contact.EmailAddresses[EmailAddressKey.EmailAddress1].Address);

                        //    foreach (NameResolution nm in nd)
                        //{
                        //        if (nm.Mailbox.RoutingType =="SMTP")
                        //    {
                        //           Console.WriteLine ( nm.Mailbox.Address); 
                        //        }
                        //    }

                        //      Console.ReadLine();
                        //    //   Console.WriteLine(contact.AssistantName);
                    }
                }

               

                Console.WriteLine(contactItems);
               Console.ReadLine();

            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                Console.ReadLine();
            }
        }


    }

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 开源仓储管理系统(Open Source Warehouse Management System,简称:OWMS)是一种免费、开源的仓储管理软件,OWMS借助现代化的信息技术手段为用户提供了仓储管理的全流程解决方案。 OWMS支持WMS(Warehouse Management System)业务流程的全面覆盖,包括收货、上架、存储、盘点、出库等各个环节,并提供了WCS(Warehouse Control System)物流控制和WES(Warehouse Execution System)执行单元管理模块,是一款全方位满足仓储管理需求的软件。 OWMS采用了分布式的架构,可以无限扩展,支持多仓库、多渠道、多客户、多语言等各种复杂需求,而且支持多种常用的数据库,可以满足不同用户的特定需求。 OWMS的优势还体现在其对于物流和仓储业务的协同支持上,它可以与ERP、TMS等各类系统无缝对接,实现信息共享,协同管理,提升仓储及物流效率。此外,OWMS还支持移动端,使管理人员可以随时随地的查看和操作仓储业务,大大方便了管理操作。 总之,OWMS作为一种优秀的开源仓储管理系统,拥有强劲的业务支持、高度的扩展性、出色的协同能力和方便的移动端使用体验,是目前市场上最受欢迎,最领先的仓储管理软件之一,值得用户们选择使用。 ### 回答2: 目前,随着电子商务的发展,仓储管理日益成为重要的管理环节,促进了商业物流流通速度的提升。而自主研发仓储管理系统,则是商家实现自我管理、节约成本的有力手段。开源仓储管理系统 c作为一款功能丰富的开源软件,能够帮助商家更好地管理其仓储流程。 开源仓储管理系统 c提供了许多核心功能,如入库管理、出库管理、库存管理、订单管理、采购管理、销售管理等。它的开源特性可以让商家根据自己的需求进行二次开发,根据各类业务需求进行扩充和优化,更好地贴合商家的业务流程。与此同时,开源仓储管理系统 c还具有易用性、灵活性、安全性等方面方面的优势,让商家的数据得到高度保障。 另外,开源仓储管理系统 c还支持跨平台、多语言、多货币等功能,帮助商家快速拓展国内外市场。它还提供了完善的管理报表系统,能够进行数据分析和决策支持,提升管理决策效率。 综上所述,开源仓储管理系统 c是一款功能强大、灵活易用、安全稳定的开源软件,为商家提供了一种高效、低成本的仓储管理解决方案。随着大数据、人工智能等技术的发展,相信它将逐渐成为商家数字化转型的重要工具,推动商业物流数字化、智能化水平的进一步提升。 ### 回答3: 开源仓储管理系统c,是一个完全免费的仓储管理软件,可在Linux系统中使用。它是由一群热爱开源技术的开发者联合开发的,旨在为用户提供高效、可靠、易用的仓储管理工具。 c仓储管理系统可以轻松帮助您完成入库管理、出库管理、库存管理、订单管理、报表生成等重要管理工作。用户可以通过使用c仓储管理系统,及时准确地了解库存变化情况,提高仓储管理效率和准确性。 c仓储管理系统操作简单,对于初学者来说也非常易于上手。同时,它还有诸多的扩展功能,比如说条形码扫描、自动生成快递单、自定义快递商等。 除此之外,c仓储管理系统还开放了API接口,可以和其他系统进行对接,提高各个系统之间的数据共享和交流。 总之,c仓储管理系统是一款非常优秀的仓储管理软件,它不仅仅免费,而且功能丰富,操作简单,对将扩展和对接也非常友好,广泛用于各种规模的仓库管理中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值