Answered by:
send email to members of a team

Question
-
i am trying to send an email to members of a team as cc on the email. (i need the user names not the team name)
I can retrieve the team members but cant figure out a good way to add them all to the cc of the email.
when looping through the team members how do i cc them all on an emailThursday, August 20, 2009 5:45 PM
Answers
-
Hi
Please do these modification to the changes.
Once your for loop finishes contains only one systemuser
Above the For Loop EmailCCEntity, sorry some of thecode snippted is for C#
// declare a collection(Array) for the cc Enttiies.
DynamicEntity[] ccEntities = new DynamicEntity[RetrieveMembersTeamResponse.BussinessEnittiesCollection.BusinessEntties.Count];
in vb.net
Dim ccEntities() As DynamicEntity = New DynamicEntity(RetrieveMembersTeamResponse.BussinessEnittiesCollection.BusinessEntties.Count) {}
In the for loop do these changes;
dim i as integer
i = 0;
For Loop Start
Dim EmailCC As DynamicEntity = New DynamicEntity
EmailCC.Name = "activityparty"
Dim CCParty As LookupProperty = New LookupProperty
CCParty.Name = "partyid"Dim CCPartyLook As Lookup = New Lookup
CCPartyLook.type = "systemuser"
CCPartyLook.Value = New Guid(GetValueFromProperty(prop)) 'retrieve guid of userCCParty.Value = CCPartyLook
ccEntities(i) = emailCC
i = i +1
For Loop Ends
After For Loop, Do this
Dim CCProp As DynamicEntityArrayProperty = New DynamicEntityArrayProperty
CCProp.Name = "cc"
CCProp.Value = ccEntities // note this line you are assigning the Array of DynamicEntity containing all the cc elements
Email.Properties.Add(CCProp)
I think the above code should work.- Edited by Muhammad Ali Khan Friday, August 21, 2009 2:15 PM
- Proposed as answer by Muhammad Ali Khan Sunday, August 23, 2009 12:25 PM
- Marked as answer by T Bonz Friday, August 28, 2009 4:20 PM
Friday, August 21, 2009 1:26 PM
All replies
-
I think there is no built in functinoality for this purpose.
You may have to develop a custom workflow and use this workflow to sent the email.When looping through team members you can add each users to the cc (which is an arraylist of activity party)
so for each user you will create an activity party object and add it to the cc array.
After you added all the receipients to the cc property of the email. Save the email enttiy and then use the SendEmailRequestSetStateEmailRequest closing = new SetStateEmailRequest();
closing.EmailState = EmailState.Completed;
closing.EmailStatus = -1;closing.EntityId = see.activityid.Value;
SetStateEmailResponse statset = (SetStateEmailResponse)service.Execute(closing);
I hope it resolve your issue.- Proposed as answer by Muhammad Ali Khan Friday, August 21, 2009 8:44 AM
Thursday, August 20, 2009 6:51 PM -
my problem is adding more than one person to the cc field
i can add one to the cc but then the rest disappear when i loop through them
how do i add more than one person to the cc?Friday, August 21, 2009 11:59 AM -
Hi,
Check this post , it would help
http://nishantrana.wordpress.com/2008/07/11/creating-and-sending-email-in-crm/
use email.cc instead of email.to !
Regards,
Nishant Rana
http://nishantrana.wordpress.comFriday, August 21, 2009 12:17 PM -
Hi.
Could you give your code for investigation?
Truth is opened the prepared mind My blog - http://a33ik.blogspot.comFriday, August 21, 2009 12:21 PMModerator -
Dim RetrieveMembersTeamRequest As RetrieveMembersTeamRequest = New RetrieveMembersTeamRequest 'RetrieveMembersTeamRequest.EntityId = GuidTeam RetrieveMembersTeamRequest.MemberColumnSet = New AllColumns() RetrieveMembersTeamRequest.ReturnDynamicEntities = True Dim RetrieveMembersTeamResponse As RetrieveMembersTeamResponse = CType(crmService.Execute(RetrieveMembersTeamRequest), RetrieveMembersTeamResponse) Dim prop As [Property] If Not RetrieveMembersTeamResponse.BusinessEntityCollection.BusinessEntities Is Nothing Then Dim TeamBusinessEntity As BusinessEntity For Each TeamBusinessEntity In RetrieveMembersTeamResponse.BusinessEntityCollection.BusinessEntities Dim retrievedTeamMember As DynamicEntity = CType(TeamBusinessEntity, DynamicEntity) For Each prop In retrievedTeamMember.Properties If prop.Name.ToString = "systemuserid" Then Dim EmailCC As DynamicEntity = New DynamicEntity EmailCC.Name = "activityparty" Dim CCParty As LookupProperty = New LookupProperty CCParty.Name = "partyid" Dim CCPartyLook As Lookup = New Lookup CCPartyLook.type = "systemuser" CCPartyLook.Value = New Guid(GetValueFromProperty(prop)) 'retrieve guid of user CCParty.Value = CCPartyLook EmailCCEntity.Properties.Add(CCParty) End If Next Next End If Dim CCProp As DynamicEntityArrayProperty = New DynamicEntityArrayProperty CCProp.Name = "cc" CCProp.Value = New DynamicEntity() {EmailCCEntity} Email.Properties.Add(CCProp)
Friday, August 21, 2009 12:30 PM -
so im having issue creating an activityparty array from the example
errors out -- to many arguments for new, whats wrong with the below
Dim
ap As activityparty() = New activityparty(10)
Friday, August 21, 2009 1:08 PM -
Hi
Please do these modification to the changes.
Once your for loop finishes contains only one systemuser
Above the For Loop EmailCCEntity, sorry some of thecode snippted is for C#
// declare a collection(Array) for the cc Enttiies.
DynamicEntity[] ccEntities = new DynamicEntity[RetrieveMembersTeamResponse.BussinessEnittiesCollection.BusinessEntties.Count];
in vb.net
Dim ccEntities() As DynamicEntity = New DynamicEntity(RetrieveMembersTeamResponse.BussinessEnittiesCollection.BusinessEntties.Count) {}
In the for loop do these changes;
dim i as integer
i = 0;
For Loop Start
Dim EmailCC As DynamicEntity = New DynamicEntity
EmailCC.Name = "activityparty"
Dim CCParty As LookupProperty = New LookupProperty
CCParty.Name = "partyid"Dim CCPartyLook As Lookup = New Lookup
CCPartyLook.type = "systemuser"
CCPartyLook.Value = New Guid(GetValueFromProperty(prop)) 'retrieve guid of userCCParty.Value = CCPartyLook
ccEntities(i) = emailCC
i = i +1
For Loop Ends
After For Loop, Do this
Dim CCProp As DynamicEntityArrayProperty = New DynamicEntityArrayProperty
CCProp.Name = "cc"
CCProp.Value = ccEntities // note this line you are assigning the Array of DynamicEntity containing all the cc elements
Email.Properties.Add(CCProp)
I think the above code should work.- Edited by Muhammad Ali Khan Friday, August 21, 2009 2:15 PM
- Proposed as answer by Muhammad Ali Khan Sunday, August 23, 2009 12:25 PM
- Marked as answer by T Bonz Friday, August 28, 2009 4:20 PM
Friday, August 21, 2009 1:26 PM