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 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
add comment

3 Answers 3

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 : http://www.4guysfromrolla.com/articles/072606-1.aspx

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
add comment

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
add comment

I published a similar solution a while back. http://sharepointa1a.codeplex.com/

share|improve this answer
add comment

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.