1. Use a SendEmail activity.
We can actually do this a few different ways:
- Bind the activity's properties to variables in your workflow and set the values pseudo-statically:
private mySendEmailActivity_From = "From Address";
private mySendEmailActivity_To = "To Address";
private mySendEmailActivity_Subject = "Subject";
private mySendEmailActivity_Body = "Body";
- (Some say this causes runtime errors!) Just set the properties on the activity itself prior to running it:
private void notifyHr_MethodInvoking(object sender, EventArgs e)
mySendEmailActivity.To = "To Address";
mySendEmailActivity.From = "From Address";
mySendEmailActivity.Subject = "Subject";
mySendEmailActivity.Body = "Body";
- Bind the properties statically AND set them dynamically, which would be about the length of the above two examples added together.
2. Code it yourself!
Many find it more reliable to insert a Code activity and bind it to the following procedure:
public void sendRejectionEmail()That's just one long line of code.
SPUtility.SendEmail(workflowProperties.Web, true, false, workflowProperties.OriginatorEmail, "HR-1 Rejected!", "pwn'd by the approvers! Mwahahaaaa!!!");
So... using the above one-liner should not take any longer to write than using the SendEmail activity.