문제

SputeStility.sendEmail () 메서드를 사용하여 SharePoint에서 전자 메일을 보냅니다.그러나 이제이 이메일로 여러 .ics 파일 (Outlook Meeting Requests)을 첨부해야합니다.

하나의 옵션 만 있으면 척추성 방법 만 사용해야합니다.우리는 어떻게이 목표를 달성 할 수 있습니까?

도움이 되었습니까?

해결책

이 방법을 사용하여 첨부 파일을 보낼 수는 없습니다.그러나 SPAdministrationWebApplication을 사용하여 SMTP 서버 세부 정보를 얻을 수 있습니다.

여기에 샘플 코드가 있습니다 :

//Get the Sharepoint SMTP information from the SPAdministrationWebApplication
string smtpServer = SPAdministrationWebApplication.Local.OutboundMailServiceInstance
.Server.Address;
string smtpFrom = SPAdministrationWebApplication.Local.OutboundMailSenderAddress;

//Create the mail message and supply it with from and to info

MailMessage mailMessage = new MailMessage(smtpFrom, insert_receiver);

//Set the subject and body of the message
mailMessage.Subject = insert_subject;
mailMessage.Body = insert_body;

//Download the content of the file with a WebClient
WebClient webClient = new WebClient();

//Supply the WebClient with the network credentials of our user
webClient.Credentials = CredentialCache.DefaultNetworkCredentials;

//Download the byte array of the file
byte[] data = webClient.DownloadData(insert_ attachment_url);

//Dump the byte array in a memory stream because
//we can write it to our attachment
MemoryStream memoryStreamOfFile = new MemoryStream(data);

//Add the attachment
mailMessage.Attachments.Add(new System.Net.Mail.Attachment(memoryStreamOfFile, insert_filename_attachment, insert_content_type));

//Create the SMTP client object and send the message
SmtpClient smtpClient = new SmtpClient(smtpServer);
smtpClient.Send(mailMessage);
.

소스에 링크 <./ a>

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top