Вопрос

Мы отправляем электронное письмо от SharePoint с помощью метода SPUTILIVY.sendemail ().Но теперь мне нужно приложить несколько файлов .ics (запросы заседаний Outlook) с этим по электронной почте.

У меня есть только один вариант, я должен использовать только метод стиховности.Как мы можем достичь этой цели?

Это было полезно?

Решение

Нет возможности отправлять вложения, используя этот метод.Но вы можете использовать SPADMInistrationWebaplication, чтобы получить данные 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);
.

Ссылка на Source

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top