Take the 2-minute tour ×
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

2 Answers 2

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

Look at this article. Should help:

http://manasbhardwaj.net/how-to-send-email-using-sharepoint/

share|improve this answer
2  
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  PirateEric Aug 20 '13 at 20:53
    
While this may theoretically answer the question, we prefer inclusion of the essential parts of the answer here, and to provide the link for reference. See answer for general guidelines. Also we require disclosure of any affiliation with products or websites. Please see May I promote products or websites I am affiliated with here? for guidelines. –  SPDoctor Aug 21 '13 at 9:30

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.