我想创建一个程序,使其能够在别人的Outlook日历中创建约会。例如:如果有人向老板提出5天免费,老板需要批准并立即将其显示在个人的Outlook日历中。我试着用EWS编码,但是我总是得到这个错误: Microsoft.Exchange.WebServices.dll中发生未处理的“Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException”类型的异常 附加信息:自动发现阻止了潜在的不安全重定向到使用EWS创建与c#的约会
这里是我的代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Exchange.WebServices.Data;
namespace exchangetest
{
public partial class Test1 : Form
{
public Test1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ExchangeService service = new ExchangeService();
service.UseDefaultCredentials = true;
service.Credentials = new WebCredentials("[email protected]", "password");
service.AutodiscoverUrl("[email protected]");
Appointment appointment = new Appointment(service);
// Set the properties on the appointment object to create the appointment.
appointment.Subject = "Tennis lesson";
appointment.Body = "Focus on backhand this week.";
appointment.Start = DateTime.Now.AddDays(2);
appointment.End = appointment.Start.AddHours(1);
appointment.Location = "Tennis club";
appointment.ReminderDueBy = DateTime.Now;
// Save the appointment to your calendar.
appointment.Save(SendInvitationsMode.SendToNone);
// Verify that the appointment was created by using the appointment's item ID.
Item item = Item.Bind(service, appointment.Id, new PropertySet(ItemSchema.Subject));
}
}
}
我真的希望有人能帮助我与此有关。
复制/粘贴你越来越让别人找到你的解决方案,一旦它会回答错误。图像没有编入索引。 – phaberest
您是否尝试过直接设置服务的URL,而不是使用AutoDiscover? –
我曾尝试手动添加URL,但也许我做错了。如果我想在[link](https://login.live.com/)上登录,我应该使用https://login.live.com/作为域名吗?无论如何,我有相同的错误代码。 –