How we can send email after "CompleteTask" event?
-
Friday, April 13, 2012 4:30 AM
Hello all,
I have created a workflow in visual studio 2010. I drag and drop SendEmail activity after "CompleteTask" event. But when a task completes Email does not sent. I dont know what i am missing. Can we send Email when a task completed?. Following is the code and image (SendEmail2 activity)which iam using. If iam missing any thing please correct it, Thanks in advance.
Dim headers As New StringDictionary()
headers.Add("to", workflowProperties.OriginatorUser.Email)
headers.Add("cc", "mareena.arrora@nrspbank.com")
headers.Add("from", createTask1_TaskProperties1.AssignedTo)
headers.Add("subject", "Your leave application has been approved")
headers.Add("content-type", "text/html")Dim bodyText As String = "Your leave application has been approved."
SPUtility.SendEmail(workflowProperties.Web, headers, bodyText)
All Replies
-
Friday, April 13, 2012 7:02 AM
Marreena,
Why are you sending mails using the SPUtility? The activity is capable of sending mails itself.
You just need to set the properties of To, From addresses and so on for the sendEmail object and mails should be sent?
An e.g. is
sendEmail.To = "ToAdress@domain.com";
set all properties and you should be good.
Please refer this blog post for more information: http://blogs.msdn.com/b/chandru/archive/2010/03/09/sending-customized-email-from-sharepoint-workflow.aspx
Regards, Huzefa Mala, MCTS
Please mark the post that answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem. -
Friday, April 13, 2012 7:09 AM
Thanks for the reply,
I use SendEmail Activity after the "CompleteTask" event and this does not work. While i had used this SendEmail activity after "CreateTask" Event and then it works great. Why SendEmail activity does not work after "CompleteTask event" ???. That is the problem, Thanks.
-
Friday, April 13, 2012 7:20 AMPlease check the workflow history to see if there is any error captured there.
Regards, Huzefa Mala, MCTS
Please mark the post that answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem. -
Friday, April 13, 2012 7:31 AM
Thanks,
History always display a message even email send (On "CreateTask") or not (On "CompleteTask") . Error is following.
4/13/2012 12:26 PM Error 
System Account The e-mail message cannot be sent. Make sure the e-mail has a valid recipient. -
Friday, April 13, 2012 8:01 AM
Keep your recipient name in a custome property created at createTask. Use that property later after completeTask. Your Email sending is failing as the contest is losing the User's email .
Ashish Ranjan (Please click "Marked As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you)
- Marked As Answer by Marreena Wednesday, May 09, 2012 6:11 AM
-
Friday, April 13, 2012 10:54 AM
Please refer the following post:
http://sharepointissues.blogspot.in/2010/08/mails-not-going-through-sendemail.html
Regards, Huzefa Mala, MCTS
Please mark the post that answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem. -
Friday, April 13, 2012 11:31 AM
Thanks for the reply,
The following line of code have no problem and always produce a value after the task completed. The complete code in my first thread have no problem in setting values like from, to subject, body. All values are coming right in SendEmail activity after the "CompleteTask" event. But email does not send. Tired of trying again n again :(.
headers.Add("to", workflowProperties.OriginatorUser.Email)

