Custom Task Email for SharePoint State Machine Workflows
-
09-12-2019 - |
Question
I have created a SharePoint State Machine workflow in Visual Studio 2010 and all works fine and all emails are sent out correctly. I would like to change the content of the email that is sent out (i.e custom subject, email body, etc.) Is this possible in VS2010? I know you can do this in SPD workflow by manipulating properties, but can this be done the same in Visual Studio? Is their a way to import the solution package in to SPD to be changed?
Would I be able to use the createTask option in my stateInitialization Activity as well as the onTaskChanged eventDriven Activity to make this happen?
Solution
For workflow Task Email you can only change the email body and the subject line must stay the same. To change the email body do the following
Just do like this within your MethodInvoking statement for the state you are sending out a custom email
this.myTaskProperties.EmailBody = "define your custom message body here. You can write html";
this.myTaskProperties.SendEmailNotification = true;
OTHER TIPS
this.myTaskProperties.EmailBody = "Define your custom message body here. You can write html";
this.myTaskProperties.SendEmailNotification = true;
this.myTaskProperties.HasCustomEmailBody = true;
The above worked for me.