I'm trying to develop event registration form using anonymous SharePoint 2010 custom list. Now, I got all the features I want; form fields, submit button that leads to confirmation page, but I want this form to send confirmation email; whenever a user register to the event he/she suppose to receive confirmation email to attend.
2 Answers
If your SharePoint has SMTP configured you can use following helper function to send email: You can pass SPWeb object using
SPContext.Current.Web
public static void SendEmail(SPWeb web, string mailTo, string mailSub, ref string mailMsg)
{
var header = new StringDictionary();
header.Add("to", mailTo);
header.Add("subject", mailSub);
header.Add("content-type", "text");
SPUtility.SendEmail(web, header, mailMsg);
}
If you don't have SMTP configured in SharePoint, use code something like this or search web for "send email .NET".
-
Just a notice, if you will send e-mail in the event receiver code, you cannot use SPContext.Current objects there. You will need to use properties.Web instead– TimCommented Nov 21, 2013 at 14:05
I'm not sure if i understood you well, but you want that when a new event is added to the list, an email is sent to someone is that correct?
Basically to do that you should check the list event receivers here, this way you can add to your list the events and basically on the items add you can write some code to send emails, you can either write your own code using .Net mail objects or you have a sharepoint email system which you can also use to send emails.
I hope i could help you a bit or send you to a right direction