send an email to manager through code

  • 20 November 2007
  • 4 replies
  • 0 views

Badge +3

Hello,


 i tried to use code to send a mail, and i couldnt find out how to send a mail to someone's manager.


for example, i can send a mail to Originator with the following line code :


  strEmail = K2.ProcessInstance.Originator.Email


However, if i want to send a mail to Originator's manager, how can i code this?


the object K2.ProcessInstance.Originator.Manager does exist but it's simply a string and no email is attached to this object.


Thank you for your help.


4 replies

Badge +9

For the activity that contains the email event, you could set the Destination rule to the Originator's Manager.  Then the server event can be configured to send to the Destination users and K2 will resolve the email for you.


HTH.

Badge +3

Yes, i know this is possible however i want to add some logic :


if (condition)


send email to originator


else


send email to originator's manager


 


and i dont think you can do this without code, right? Unless you use 2 separate activities, one with originator as destination rule, the other with manager as destination rule, and you put the logic in the links. But i wuold like to avoid such a big solution if i can use a few lines of code instead, and have it in a single activity.


 

Badge +9

As long as the (condition) data resides within K2 data/XML fields, I don't think you'll need to write any code, or use multiple activities.


Activity Destination Rules can have multiple destination sets, with rules around when to use each destination set.  Take a look at the below posting which shows in detail how to create multiple destination sets and add rule logic to determine when each are used.


http://k2underground.com/forums/thread/7209.aspx


 

Badge +3

Oh,


 


i didnt know that this features existed. It's exactly what i needed. Thanks a lot for your help.

Reply