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: http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/a0292b6b-e412-4ccb-910d-1df90f90d5d9. 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.Send(message);
smtpClient = null;
message.Dispose();

Advertisements

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:

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: