locked
How to edit email message sent by CreateTaskWithContentType activity? RRS feed

  • Question

  • I have created a custom document approval workflow in Visual Studio 2008. When workflow creates a task the approver gets a email created from the wrong template "A new Page Needs your Approval to add to MySite". Looks like message is coming from another workflow. But I create a task base on my custom content type. How to add email template for my workflow?


    Oleg
    Friday, May 20, 2011 8:13 PM

Answers

All replies

  • Hi Oleg,

    You can create a custom email with the SPUtility.SendEmail method, refer to,
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.sendemail.aspx
    And there is a short article about the html format in email body, you can read it,
    http://sharepointserved.blogspot.com/2011/05/send-email-with-html-format-using.html

    Another way, you can create a custom email with sendEmailActivity, you can refer to this article,
    http://www.codeproject.com/KB/WF/SendEmailCustomActivity.aspx

     

    Thanks & Regards,
    Daniel

    • Marked as answer by Wayne Fan Friday, June 3, 2011 3:07 AM
    Tuesday, May 24, 2011 12:23 PM
    Moderator
  • Thank you for suggestion but this solution is not fix for my issue. I will use custom sendemail just if I will not have another choice.

    I have added to createApprovalTask_MethodInvoking:

          createFirstApprovalTask.TaskProperties.HasCustomEmailBody = true;
          createFirstApprovalTask.TaskProperties.EmailBody = "A new Document needs your Approval.";
          createFirstApprovalTask.TaskProperties.SendEmailNotification = true;
    
    

    but I still get a message from another workflow. Does HasCustomEmailBody actually work?


    Oleg
    Wednesday, May 25, 2011 8:34 PM
  • Did you set the value for "AsignTo"? If not you can add it and try it again.

    e.g.

    taskProperties.Title = "Approval";
    taskProperties.StartDate = DateTime.Today;
    taskProperties.PercentComplete = 0.0f;
    taskProperties.AssignedTo = username or groupname;
    

    • Marked as answer by Wayne Fan Friday, June 3, 2011 3:07 AM
    Friday, May 27, 2011 9:18 AM
    Moderator