Tag: office365

Office 365使用OutlookServicesClient发送带附件的电子邮件

我正在尝试代表我的LOB应用程序的用户发送一些电子邮件。 我正在使用Office 365连接服务API,以便我可以使用OAuth进行身份validation。 我的代码将发送电子邮件,但没有附件显示。 这是我的代码的一个孤立的例子: static async void SendUsingOutlookClient(CommunicationRow me, OutlookServicesClient outlook) { var m = new Message(); m.From = ToRecipient(me.From); m.Body = new ItemBody { Content = me.Body }; if (me.IsBodyHtml) m.Body.ContentType = BodyType.HTML; else m.Body.ContentType = BodyType.Text; m.Subject = me.Subject; m.CcRecipients.Add(me.Cc); m.BccRecipients.Add(me.Bcc); m.ToRecipients.Add(me.To); foreach (var attach in me.Attachments) { var file = attach.File; […]

无需用户交互即可获取Office 365 API访问令牌

我想为我的应用程序添加一个function,以便它能够在没有用户交互的情况下向outlook.com添加日历事件。 我见过的所有示例都要求用户登录才能访问office 365 api令牌。 如何在没有用户交互的情况下获得该令牌?

“无法以静默方式获取令牌。 调用方法AcquireToken“

try { ClientCredential clientCredential = new ClientCredential(“***********”,”**************”); UserIdentifier userIdentifier = new UserIdentifier(userObjectId, UserIdentifierType.UniqueId); DiscoveryClient discClient = new DiscoveryClient(SettingsHelper.DiscoveryServiceEndpointUri, async () => { var authResult = await authContext.AcquireTokenSilentAsync(SettingsHelper.DiscoveryServiceResourceId, clientCredential, userIdentifier); return authResult.AccessToken; }); var dcr = await discClient.DiscoverCapabilityAsync(capabilityName); return new OutlookServicesClient(dcr.ServiceEndpointUri, async () => { var authResult = await authContext.AcquireTokenSilentAsync(dcr.ServiceResourceId, clientCredential, userIdentifier); return authResult.AccessToken; }); } […]

从SharePoint 365下载文件

string remoteUri = “http://www.contoso.com/library/homepage/images/”; string fileName = “ms-banner.gif”, myStringWebResource = null; // Create a new WebClient instance. WebClient myWebClient = new WebClient(); // Concatenate the domain with the Web resource filename. myStringWebResource = remoteUri + fileName; Console.WriteLine(“Downloading File \”{0}\” from \”{1}\” …….\n\n”, fileName, myStringWebResource); // Download the Web resource and save it into the current […]

尝试通过Office 365发送电子邮件时SMTP 5.7.57错误

我正在尝试设置一些代码以通过Office 365经过身份validation的SMTP服务发送电子邮件: var _mailServer = new SmtpClient(); _mailServer.UseDefaultCredentials = false; _mailServer.Credentials = new NetworkCredential(“test.user@mydomain.com”, “password”); _mailServer.Host = “smtp.office365.com”; _mailServer.TargetName = “STARTTLS/smtp.office365.com”; // same behaviour if this lien is removed _mailServer.Port = 587; _mailServer.EnableSsl = true; var eml = new MailMessage(); eml.Sender = new MailAddress(“test.user@mydomain.com”); eml.From = eml.Sender; eml.to = new MailAddress(“test.recipient@anotherdomain.com”); eml.Subject = “Test message”; […]

使用OAuth2在Office 365中进行IMAP身份validation

我在我的程序中使用IMAP客户端。 我正在尝试使用OAuth2机制(使用这些说明 )通过IMAP客户端访问Office 365 Outlook。 当我在IMAP客户端中进行身份validation时 – 身份validation失败,但Google和Outlook.com的OAuth2身份validation工作正常。 Office 365是否支持IMAP中的OAuth2身份validation? 如果确实如此,如何进行身份validation?

通过EWS API连接到Office 365

我在我的控制台应用程序中使用EWS API来处理邮箱项目,我的连接脚本看起来像 ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.UseDefaultCredentials = true; service.AutodiscoverUrl(“emailService@domain.com”); 但我发现我的电子邮件帐户已移至Office 365云。 我该如何更改身份validation? 我找到了EWS服务url service.Url = new Uri(“https://outlook.office365.com/EWS/Exchange.asmx”); 但我不知道如何使用它。 谢谢