We send the email from SharePoint by using SPUtility.SendEmail() method. But, now I need to attach multiple .ics file (Outlook meeting requests) with this email.

I have only one option, I have to use the SPUtility method only. How can we acheive this goal?

1 Answer 1


There is no possibility to send Attachments using this method. But you can use of SPAdministrationWebApplication to get the SMTP server details.

Here is the sample code:

//Get the Sharepoint SMTP information from the SPAdministrationWebApplication
string smtpServer = SPAdministrationWebApplication.Local.OutboundMailServiceInstance
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);

Link to source

  • what should I put instead of insert_ attachment_url ?
    – Arezo
    Commented Aug 24, 2017 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.