我想創建一個程序,使其能夠在別人的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/作爲域名嗎?無論如何,我有相同的錯誤代碼。 –