Sharepoint与Office 365的在线电子邮件集成
本文关键字:在线 电子邮件 集成 Office Sharepoint | 更新日期: 2024-07-23 01:27:13
我目前正试图找到一个选项,说明如何在outlook web应用程序中打开存储在Sharepoint Online中的电子邮件。这意味着我已经从Outlook拖动了一封电子邮件,并在SharePoint在线文档库中拖动。但是,我想通过SP在线回复电子邮件,只需单击该项目(然后在Outlook web应用程序中打开)。
如果这不是开箱即用的,有没有办法为它创建一个应用程序,例如使用Outlook web api来实现此功能?
以*.msg文件格式保存电子邮件并将文件上载到SharePoint Online时,它不会在Outlook Web App(OWA)中打开,因为OWA不理解*.msg的文件格式(富文件格式)。您可以下载该文件并使用outlook客户端打开。
如果你想创建一个应用程序来实现这一点。在c#中,您可以通过以下步骤使用SharePoint客户端dll:
1.向SharePoint发送通过用户名和密码创建的凭据对象的请求:
ClientContext context = new ClientContext(SiteUrl);
context.Credentials = new SharePointOnlineCredentials(UserName, Password);
2.提供从中读取数据的文件url。msg文件:
public Stream GetFile()
{
using (ClientContext clientContext = GetContextObject())
{
Web web = clientContext.Web;
clientContext.Load(web, website => website.ServerRelativeUrl);
clientContext.ExecuteQuery();
Regex regex = new Regex(SiteUrl, RegexOptions.IgnoreCase);
string strSiteRelavtiveURL = regex.Replace(FileUrl, string.Empty);
string strServerRelativeURL = CombineUrl(web.ServerRelativeUrl, strSiteRelavtiveURL);
Microsoft.SharePoint.Client.File oFile = web.GetFileByServerRelativeUrl(strServerRelativeURL);
clientContext.Load(oFile);
ClientResult<Stream> stream = oFile.OpenBinaryStream();
clientContext.ExecuteQuery();
return this.ReadFully(stream.Value);
}
}
3.你可以下载带有FileStream对象的.msg文件(点击此处下载整个演示)。之后,你可以使用c#从文件中读取信息,然后通过System.Net.Mail.MailMessage:发送电子邮件
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
SmtpClient SmtpServer = new SmtpClient("servername");
mail.From = new MailAddress(strFromAddress);
mail.To.Add(strToAddress);
mail.Subject = strSubject;
mail.Body = strMessage;
SmtpServer.Send(mail);