didonato
8 years agoCreator II
Set Relationship from TEAM
I'm trying to send a email to users from a TEAM within a workflow. Since the workflow "notifications" won't let me include a attachment. I created a method to do this, but I don't know how to setup the relationship for the Team Roles. Below is my code, without the attachment information.
Also, will the team users from the "send to" below email all users or just one user.
// *** ECP ********************************************************* //
Item hd= inn.newItem("Express ECO","get");
hd.setID(this.getID());
hd.setAttribute("select","item_number,team_id");
hd = hd.apply();
// *** Email From ********************************************************** //
Item innAdm= inn.newItem("User","get");
innAdm.setAttribute("select","first_name,last_name,email");
innAdm.setProperty("login_name","admin");
innAdm=innAdm.apply();
// *** Email To ************************************************************ //
// *** I'm not sure how to use addRelationship(), so I tried it this way *********//
Item teamID= inn.newItem("team_identity","get");
teamID.setProperty("source_id",hd.getProperty("team_id"));
teamID.setProperty("team_role","6D22DAAF10654038B177A60785E4AA8D");
teamID.setAttribute("select","source_id,team_role,related_id");
Item toUser= inn.newItem("User","get");
toUser.setAttribute("select","id,email,keyed_name");
toUser.setProperty("owned_by_id",teamID.getProperty("related_id"));
toUser=toUser.apply();
// *** Email Information *************************************************** //
string from_user=innAdm.getProperty("email");
string from_userN = innAdm.getProperty("first_name")+ " " + innAdm.getProperty("last_name");
string to_user=toUser.getProperty("email");
string emBody= "<body>You have been identified as one of the members of the CM Team."
;
System.Net.Mail.MailAddress SendFrom = new System.Net.Mail.MailAddress(from_user,from_userN);
System.Net.Mail.MailAddress SendTo = new System.Net.Mail.MailAddress(to_user);
System.Net.Mail.MailMessage MyMessage = new System.Net.Mail.MailMessage(SendFrom, SendTo);
MyMessage.Subject = "ECP Number: " + hd.getProperty("item_number");
MyMessage.IsBodyHtml = true;
MyMessage.Body = emBody;
return this;