How to send email in SharePoint

June 7th, 2009 | Categories: SharePoint, WSS 3.0 | Tags: ,

 

private void SendEmail()

        {

            // Build the email subject

            System.Text.StringBuilder subject = new System.Text.StringBuilder();

            subject.Append(“New TimeSheet has been added “);

            subject.Append(txtEmailAddress.Text);

 

            // Build the email body message

            System.Text.StringBuilder message = new System.Text.StringBuilder();

            message.Append(“Employee Name: “);

            message.AppendLine(txtEmpName.Text.Trim());

            message.AppendLine();

            message.Append(“Email Address: “);

            message.AppendLine(txtEmailAddress.Text);

            message.AppendLine();

            message.Append(“WeekEnd: “);

            message.AppendLine(WeekCalendar.SelectedItem.Text.Trim());

            message.AppendLine();

           

 

            // Construct the message header

            System.Collections.Specialized.StringDictionary messageInfo =

            new System.Collections.Specialized.StringDictionary();

           

// Where to send the email

            messageInfo.Add(“to”, “himadrish@gmail.com”);

            // From which email account this email

messageInfo.Add(“from”, “himadrish@hotmail.com”);                 

           

messageInfo.Add(“content-type”, “text/plain”);

messageInfo.Add(“subject”, subject.ToString());

           

            // Send the email

Microsoft.SharePoint.Utilities.SPUtility.SendEmail(SPContext.Current.Web, messageInfo, message.ToString());

 

        }

 

It requires that your IIS/WFS SMTP engine is running to execute this email.

  1. June 16th, 2009 at 19:23

    How soon will you update your blog? I’m interested in reading some more information on this issue.

  2. Himadrish
    June 17th, 2009 at 18:36

    Thanks Gary for your post.

    As this is new born baby now, so it will take some time from designing and decoration aspect. However I promise to post article atleast twice in a month.

  3. Hey, nice post, really well written. You should write more about this.

  4. Me and my close friend had been arguing about an issue related to this! Now I know that I was correct. lol! Appreciate it for the details you post.

You must be logged in to post a comment.