Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:19:33+00:00 2026-06-02T16:19:33+00:00

I have a Web Part in SharePoint 2010 that has an Event Receiver that

  • 0

I have a Web Part in SharePoint 2010 that has an Event Receiver that fires when an item is added to a list. The Event Receiver is supposed to send a mail but does not.

It works fine when I try without the Event Receiver, how can I send mail using an Event Receiver?

StringDictionary headers = new StringDictionary();
string body = "Hi!";
headers.Add("to", "paulo@paulo.se");
headers.Add("from", "paulosaysno@paulo.se");
headers.Add("subject", "Paulo says hi");
headers.Add("content-type", "text/html");
SPUtility.SendEmail(web, headers, body)

Thank you for helping.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:19:35+00:00Added an answer on June 2, 2026 at 4:19 pm

    And event receiver runs in the context of an HTTP request. It is known that SPUtility.SendEmail has issues with this. A common practice is to set HttpContext.Current to null while sending the email:

    SPWeb thisWeb = thisSite.RootWeb;
    string toField = "someone@microsoft.com";
    string subject = "Test Message";
    string body = "Message sent from SharePoint";
    HttpContext oldContext = HttpContext.Current;
    HttpContext.Current = null;
    
    bool success = SPUtility.SendEmail(thisWeb, true, true, toField, subject, body);
    HttpContext.Current = oldContext;
    

    Reference (scroll down to the comments): http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.sendemail(v=office.12).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Sharepoint 2010 Current User Filter Web Part allows List Web Parts that have
I have developed a web part that has to be deployed on a Sharepoint
In SharePoint 2010 I have a visual web part that uses SP.UI.ModalDialog.showModalDialog The dialog
I am developing silverlight web part for sharepoint 2010. In my project I have
I have a SharePoint 2010 web part in minimize mode, what I want is
I have a custom sharepoint web part that is throwing the following exception: System.Security.SecurityException:
I have a Sharepoint 2010 site with a Silverlight web part. When someone comes
I have a SharePoint web part that I wrote in C# which is used
Background: I have a built-in-house custom SharePoint 2010 web part, inheriting from System.Web.UI.WebControls.WebParts.WebPart ,
I am working on sharepoint 2010. I have created a simple visual web part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.