fix
So, here is another interesting nugget of entertainment …. this time the idea was given to me by Donabel.
If you ever wondered – “can i get a hold of all that information and settings that sharepoint holds” – the answer is yes … sharepoint exposes object model that allows you to retrieve some of it’s settings entered by admins(for instance) while setting up the portal.
As an example – here I will post a method (contributed by Donabel) that allows you to get default SMTP server name – so that you can use it in your application and not expose redundant settings and properties that someone has to fill in …
private string GetSmtpServer()
{
SPWebApplicationCollection spWebApplicationCollection = SPWebService.ContentService.WebApplications;
SPOutboundMailServiceInstance smtpServer = new SPOutboundMailServiceInstance();
if (spWebApplicationCollection != null)
{
foreach (SPWebApplication spWebApplication in spWebApplicationCollection)
{
smtpServer = spWebApplication.OutboundMailServiceInstance;
return smtpServer.Server.Address;
}
}
return string.Empty;
}