string smtpServer = SPAdministrationWebApplication.Local.OutboundMailServiceInstance.Server.Address;
string smtpFrom = SPAdministrationWebApplication.Local.OutboundMailSenderAddress;
string smtpFrom = SPAdministrationWebApplication.Local.OutboundMailSenderAddress;
MailAddress fromAdress = new MailAddress(from);
MailAddress toAdress = new MailAddress(to);
MailAddress toAdress = new MailAddress(to);
MailMessage mailMessage = new MailMessage(fromAdress, toAdress);
mailMessage.Subject = title;
mailMessage.Body = message;
mailMessage.IsBodyHtml = true;
mailMessage.IsBodyHtml = true;
WebClient oWebClient = new WebClient();
oWebClient.Credentials = CredentialCache.DefaultNetworkCredentials;
string filename_attachment = "filename.docx";
string attachment_url = "http://<path>/file.docx";
string attachment_url = "http://<path>/file.docx";
byte[] data = oWebClient.DownloadData(attachment_url);
MemoryStream oMemoryStream = new MemoryStream(data);
mailMessage.Attachments.Add(new System.Net.Mail.
Attachment(oMemoryStream, filename_attachment, MediaTypeNames.Text.Plain));
Attachment(oMemoryStream, filename_attachment, MediaTypeNames.Text.Plain));
SmtpClient oSmtpClient = new SmtpClient(smtpServer);
oSmtpClient.Send(mailMessage);
oSmtpClient.Send(mailMessage);
Комментариев нет:
Отправить комментарий