Sign up ×
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

3 Answers 3

up vote 22 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

In SharePoint you can configure the outgoing email settings at two locations in the Central Admin.

  • First, there is a global setting at Central Admin -> System Settings -> Configure outgoing e-mail settings (that is what was asked in the original question).

  • Second, you can configure an alternative setting for each of the web applications at Central Admin -> Application Management -> Manage web applications -> (select the web application you would like to configure) -> (select the General Settings drop-down button at the ribbon) -> Outgoing E-mail.

Via the code from Falak Mahmood you can access this later one.

If you need to access the global settings, you can do it either via the SPGlobalAdmin class:

var globalAdmin = new Microsoft.SharePoint.Administration.SPGlobalAdmin()
var smtpServer = globalAdmin.OutboundSmtpServer
var mailFromAddress = globalAdmin.MailFromAddress
var mailReplyToAddress = globalAdmin.MailReplyToAddress

Or you can access the corresponding properties of the SPAdministrationWebApplication.Local instance (of type SPAdministrationWebApplication, subtype of SPWebApplication), like OutboundMailSenderAddress or OutboundMailReplyToAddress.

Note, that the mail related properties of SPGlobalAdmin are available only as getter methods. If you want to change them, you can either call the UpdateMailSettings method:

SPAdministrationWebApplication.Local.UpdateMailSettings("", "", "", 65001);

or set the corresponding properties directly, like

var localAdminWebApp = SPAdministrationWebApplication.Local;
localAdminWebApp.Local.OutboundMailSenderAddress = "";
localAdminWebApp.OutboundMailReplyToAddress = "";
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.