SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this code for SPUtility but i don't know where to put it to send an email from my form the form includes text box to insert an email from active directory but I want the code to send an message to that email

if (!SPUtility.IsEmailServerSet(currentWeb))
    SPUtility.TransferToErrorPage("Please configure the outgoing e-mail settings in Central Administration")
share|improve this question
you want to use this code to send an email? – Furqan Jun 30 '12 at 10:20
yes i want to use this code – sarah Jun 30 '12 at 15:37

To send email from SharePoint, you can use SPUtility.SendEmail or configure 'Send Email' workflow using SharePoint designer. You need to ensure that the outgoing e-mail settings are configured in Central Administration.

If you have a custom webpart or form, you can also use SmtpClient from ASP.NET to send emails. Here is an example :

share|improve this answer
the workflow is not working that's why i want to use the sputility i just need to now where i should put this code exactly because i tried to put it inside form.aspx but thinks it should be written in another place – sarah Jun 30 '12 at 15:35

Assuming that the form you have is a list form, you can create an event receiver on item adding event, and write the sputility code to send email to the person present in the field inside that event. So when the users is adding and item and he saves an email will get generated.

share|improve this answer

I published a similar solution a while back.

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.