无需 UI 即可访问 Office 365 API
Get an access to Office 365 API without UI
我需要编写一个 .NET Core 控制台应用程序,它从 Office 365 帐户获取一些电子邮件。
是否有可能在没有任何弹出窗口的情况下访问 Office 365 API 并且 UI 使用电子邮件和密码?
我尝试了在 Azure Active Directory 中注册应用程序的解决方案,但它并不真正适合我的目的,因为登录的用户必须与特定的 AAD 帐户相关联。
我在 Stuck Overflow 上发现了这样的问题,但它们都与旧版本 API 和旧方法有关。
我找了 4 天的解决方案并阅读了大量文档,但我仍然卡住了。
以下示例使用 Exchange API - 而不是 Office 365 API。
这是登录到 Office 365 的 Exchange 服务器并将日历条目发送到电子邮件地址的示例。
//Connect to exchange
var ewsProxy = new ExchangeService(ExchangeVersion.Exchange2013);
ewsProxy.Url = new Uri("https://outlook.office365.com/ews/exchange.asmx");
//Create the meeting
var meeting = new Appointment(ewsProxy);
ewsProxy.Credentials = new NetworkCredential(_Username, _Password);
meeting.RequiredAttendees.Add(_Recipient);
// Set the properties on the meeting object to create the meeting.
meeting.Subject = "Meeting";
meeting.Body = "Please go to the meeting.";
meeting.Start = DateTime.Now.AddHours(1);
meeting.End = DateTime.Now.AddHours(2);
meeting.Location = "Location";
meeting.ReminderMinutesBeforeStart = 60;
// Save the meeting to the Calendar folder and send the meeting request.
meeting.Save(SendInvitationsMode.SendToAllAndSaveCopy);
更多信息,请查看以下链接:
Get Office 365 API access token without user interaction
我需要编写一个 .NET Core 控制台应用程序,它从 Office 365 帐户获取一些电子邮件。
是否有可能在没有任何弹出窗口的情况下访问 Office 365 API 并且 UI 使用电子邮件和密码?
我尝试了在 Azure Active Directory 中注册应用程序的解决方案,但它并不真正适合我的目的,因为登录的用户必须与特定的 AAD 帐户相关联。
我在 Stuck Overflow 上发现了这样的问题,但它们都与旧版本 API 和旧方法有关。
我找了 4 天的解决方案并阅读了大量文档,但我仍然卡住了。
以下示例使用 Exchange API - 而不是 Office 365 API。
这是登录到 Office 365 的 Exchange 服务器并将日历条目发送到电子邮件地址的示例。
//Connect to exchange
var ewsProxy = new ExchangeService(ExchangeVersion.Exchange2013);
ewsProxy.Url = new Uri("https://outlook.office365.com/ews/exchange.asmx");
//Create the meeting
var meeting = new Appointment(ewsProxy);
ewsProxy.Credentials = new NetworkCredential(_Username, _Password);
meeting.RequiredAttendees.Add(_Recipient);
// Set the properties on the meeting object to create the meeting.
meeting.Subject = "Meeting";
meeting.Body = "Please go to the meeting.";
meeting.Start = DateTime.Now.AddHours(1);
meeting.End = DateTime.Now.AddHours(2);
meeting.Location = "Location";
meeting.ReminderMinutesBeforeStart = 60;
// Save the meeting to the Calendar folder and send the meeting request.
meeting.Save(SendInvitationsMode.SendToAllAndSaveCopy);
更多信息,请查看以下链接:
Get Office 365 API access token without user interaction