locked
SendEmail activity RRS feed

  • Question

  • Im using a SendEmail activity in my workflow straight after the OnWorkflowActivated activity, i have set the correlation token to be same with the correlation token of Onworkflowactivated activity. Then, i set the following SendEmail properties on the method invoking:

     

    From = "name@something.com";

    To= "name@something.com";

    Subject = "testing";

    Body = " Just a email testing";

     

    when i start a workflow, no error occured but i did not receive any email, any idea what will be the cause of this problem?

     

    Any helps will be appreciated, thank you.

    Monday, May 14, 2007 8:44 AM

Answers

  • I think the last post was long time ago, but just for the record, I had the same problem, the way solved it was adding the the call to SendEmail function inside the SPSecurity.RunWithElevatedPrivileges.

     

    Code Snippet

    SPSecurity.RunWithElevatedPrivileges(delegate()

    {

    SPUtility.SendEmail(SPControl.GetContextWeb(HttpContext.Current), true, true, "myemail@mail.com", "my subject", "my body", true);

    });

     

     

     

    -Carlos

    Tuesday, February 12, 2008 2:19 AM

All replies

  • check once your SMTP server
    if u configure ur smtp server correctly?
    if yes, u should get it.

    SmtpClient client = new SmtpClient("localhost");

    inplace of localhost give ur server name

    MailMessage message = new MailMessage(this.From, this.To, this.Subject, this.Body);
                    client.Send(message);

    from , to , subject , body are strings that needs to send mail


    thanks
    praveen

    Monday, May 14, 2007 12:21 PM
  • thanks for your reply.

     

    I have configured the Smtp Outgoing Message in WSS, and i am able to receive email whenever a task is assigned to me

     

    But this is an activity from Workflow foundation, do i still have to set the smtpclient?

    Tuesday, May 15, 2007 1:16 AM
  • for your information, i also try to use SPUtility.IsEmailServerSet and SPUtility.SendEmail as follows, both statements return true but i still cannot receive any emails.

     

    SPSite site = new SPSite(http://mysite);

    SPWeb web = site.OpenWeb();

    Console.Write( SPUtility.IsEmailServerSet(web).ToString());

    Console.Write( SPUtility.SendEmail(web, false, false, "my@email", "testing", "Gogogo").ToString());

    Console.Read();

    Tuesday, May 15, 2007 1:46 AM
  • Do i need to set the credential in order to use SPUtility.SendEmail because i remember last time i needed to set it when i use the System.Net.Mail.

     

    Or worse come to worse, i use the System.Net.Mail to send email but any idea how can i get the SMTP server name from sharepoint?

    Tuesday, May 15, 2007 3:27 AM
  • Is the status of the workflow complete?
    Tuesday, May 15, 2007 3:56 AM
  • no, workflow is still listening to some events
    Tuesday, May 15, 2007 4:02 AM
  • Hi,

    Just wondering if u could solve this problem. I have the same exact one..

    Appreciate your reply.

     

    Thanks..

    Monday, October 29, 2007 2:40 PM
  • I think the last post was long time ago, but just for the record, I had the same problem, the way solved it was adding the the call to SendEmail function inside the SPSecurity.RunWithElevatedPrivileges.

     

    Code Snippet

    SPSecurity.RunWithElevatedPrivileges(delegate()

    {

    SPUtility.SendEmail(SPControl.GetContextWeb(HttpContext.Current), true, true, "myemail@mail.com", "my subject", "my body", true);

    });

     

     

     

    -Carlos

    Tuesday, February 12, 2008 2:19 AM
  • SPUtility.SendEmail(oWeb, true, true, user.Email, "subject", "email-body");

     

    Use this it may help. Even i was not receiving the mails when i was using

    SPUtility.SendEmail(oWeb, false, false, user.Email, "subject", "email-body");

    set fAppendHtmlTag and fHtmlEncode property to true. it will work. In my case it worked.

    Tuesday, April 1, 2008 7:52 AM
  •  

    Good Day Carlos,

    My understanding of this issue is that we are using the SendMailActivity from a Visual Studio SharePoint workflow object (I am using Visual Studio 2010) and we get the above error.

    I also got the above error and tried the code using the "RunWithElevatedPriviledges(delegate() . .  .etc which you listed above. I got the same error by using the "MethodInvoking" event handler of the SendMailActivity object.

    I did test the remainder of the workflow by setting the Sendmail Activity "Enabled" property to "false" , and the remainder of the workflow executes perfectly.

    So for me there is another issue somewhere, and I have not found it. At least two other solutions and workflows have the same error. Yes, SharePoint is sending outgoing email to me from a number of other sharepoint applications, so outgoing email is configured ok. Went through this dozens of times and was not able to find a solution. Anyone have the same experiences I had and has a solution?

     

    I received the following WARNING AND errors when building and debugging the solution:

    Warning 1 Could not load types from
    'C:\Program Files\Common Files\Microsoft Shared\Web Server
    Extensions\14\ISAPI\Microsoft.SharePoint.dll'.
    Unable to load one or more of the requested types. Retrieve
     the LoaderExceptions property for more information.  
    0 0 


    System.NullReferenceException was unhandled by user code
      Message=Object reference not set to an instance of an object.
      Source=Microsoft.SharePoint
      StackTrace:
           at Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context)
           at ch15_EventReusableWF.EventFT.<sendEmail1_MethodInvoking>b__0()
           at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()
           at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
      InnerException:

     

    BIGHAMP

     


    • Edited by InspirationIT Thursday, December 22, 2011 6:32 PM
    • Proposed as answer by InspirationIT Thursday, December 22, 2011 6:32 PM
    Thursday, December 22, 2011 6:30 PM