Outgoing email setting are configured in central administration at path:
Central Admin -> System Settings -> Configure outgoing e-mail settings
Below is the code to access outgoing e-mail settings using object model:
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Central Admin -> System Settings -> Configure outgoing e-mail settings
Below is the code to access outgoing e-mail settings using object model:
//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;
}
}
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
No comments:
Post a Comment