locked
send email to members of a team RRS feed

  • 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 email
    Thursday, 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 user

                                    CCParty.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.

    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 SendEmailRequest

    SetStateEmailRequest 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.

    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.com
    Friday, 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.com
    Friday, August 21, 2009 12:21 PM
    Moderator
  • 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 user

                                    CCParty.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.

    Friday, August 21, 2009 1:26 PM