Monday, March 18, 2013

Programmatically get SmtpClient of SharePoint web application

It is necessary to set up SmtpClient.Host property if you want to send e-mail using System.Net.Mail namespace. This can be easily done using OutboundMailServiceInstance property like this:

string smtpURL = SPContext.Current.Site.WebApplication.OutboundMailServiceInstance.Server.Address;

No comments:

Post a Comment