Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am currently working on sending an email with an iCal event that users can accept/decline to add it to their calendar. The built-in SPUtility.SendEmail is too limited to achieve this so I'm using SmtpClient instead. However, I've needed to hard code the Outbound SMTP Server shown in the image below because I've been unable to find this property from the SharePoint API:

Outbound SMTP Server

This is obviously going to cause problems when the Outbound SMTP server changes because I will have to remember to update it in 2 places. How can I access this property using the SharePoint API?

share|improve this question

1 Answer

up vote 3 down vote accepted

I found an article by Randy Drisgill that describes how to get the SMTP server by using the SPWebApplication.

The one-line code to get the property is SPContext.Current.Web.Site.WebApplication.OutboundMailServiceInstance.Server.Address.

share|improve this answer

Your Answer

 
discard

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.