SharePoint Dragons

Nikander & Margriet on SharePoint

SPUtility.SendEmail() limit

The SPUtility.SendEmail() method has a limit of the max number of characters on a single line: 2048. However, you can divide the message body in chunks of several lines, thereby circumventing the maximum: Alternatively, you can send emails directly, using code like this:

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = new System.Net.Mail.MailAddress(objWeb.Site.WebApplication.OutboundMailSenderAddress);
message.To.Add(new System.Net.Mail.MailAddress(objTcnlSite.AcmaEmail));
message.Subject = Subject;
message.Body = Body;
message.IsBodyHtml = true;
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(objWeb.Site.WebApplication.OutboundMailServiceInstance.Server.Address);
smtpClient.UseDefaultCredentials = true;
smtpClient = null;

One response to “SPUtility.SendEmail() limit

  1. Pingback: Microsoft Fakes: building a shim for the SharePoint 2013 SSOM | SharePoint Dragons

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: