Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is it possible for me to pull the values that are in:

Central Admin -> System Settings -> Configure outgoing e-mail settings

from my code behind using the object model?

share|improve this question

2 Answers 2

up vote 19 down vote accepted

Make sure that you have already configured the “Outgoing e-mail settings”.

//Get the site ID
Guid siteID = SPContext.Current.Site.ID;
protected string GetSMTPHostName()
    using (SPSite site = new SPSite(siteID))
      //Get the SMTP host name from “Outgoing e-mail settings”
      return site.WebApplication.OutboundMailServiceInstance.Parent.Name;
protected string GetFromEmailID()
    using (SPSite site = new SPSite(siteID))
      //Get the “from email address” from “Outgoing e-mail settings”
      return site.WebApplication.OutboundMailSenderAddress;


   //you can also get other properties similarly...
share|improve this answer

Yes, look for properties of SPAdministrationWebApplication, you can access it using SPAdministrationWebApplication.Local. Properties are:






Namespace: Microsoft.SharePoint.Administration

Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)

If you want to update the settings, you need to call UpdateMailSettings method.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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