locked
send email to mutli person RRS feed

  • Question

  • how can i send email to multi person using CRM SDK programaticlly by Picklist field

    myemail.to= Picklist values not Lookup

    any idea ?


    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Sunday, April 26, 2009 1:47 PM

Answers

  • Hi,

    Email entity To field accept Array of activityparty. So, first create an activityparty array and then add individual instances of activityparty object to that array and then set the value of To to that array.

    Hope this helps.

    Ayaz Ahmad Technical Consultant | Dynamics CRM/MOSS | OA Systems Ltd | http://ayazahmad.wordpress.com
    • Proposed as answer by Ayaz.AhmadModerator Monday, April 27, 2009 9:46 PM
    • Unproposed as answer by Dany85 Tuesday, April 28, 2009 6:31 AM
    • Marked as answer by Dany85 Tuesday, April 28, 2009 6:31 AM
    Sunday, April 26, 2009 9:26 PM
    Moderator

All replies

  • Hi,

    Email entity To field accept Array of activityparty. So, first create an activityparty array and then add individual instances of activityparty object to that array and then set the value of To to that array.

    Hope this helps.

    Ayaz Ahmad Technical Consultant | Dynamics CRM/MOSS | OA Systems Ltd | http://ayazahmad.wordpress.com
    • Proposed as answer by Ayaz.AhmadModerator Monday, April 27, 2009 9:46 PM
    • Unproposed as answer by Dany85 Tuesday, April 28, 2009 6:31 AM
    • Marked as answer by Dany85 Tuesday, April 28, 2009 6:31 AM
    Sunday, April 26, 2009 9:26 PM
    Moderator
  • could you write a snippet code explaining this operation?
    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Monday, April 27, 2009 6:40 AM
  • Hi,

    You could do something like this
    private void SendMailToMembers(ICrmService crmService, ArrayList members, String msg, String ownerID, String userID)
    {
    
    // create an email
    email emailCreate = new email();
    emailCreate.subject = “MySubject”;
    emailCreate.description = msg;
    
    //specify the owner for the mail
    emailCreate.ownerid = new Owner();
    emailCreate.ownerid.type = EntityName.systemuser.ToString();
    emailCreate.ownerid.Value = new Guid(ownerID);
    
    //create an activityparty array holding all the guids specified in the members array list
    activityparty[] ap = new activityparty[members.Count];
    // creating as many activity party as the no of users or members in a team
    int i = 0;
    foreach (String memberID in members)
    {
    ap[i] = new activityparty();
    ap[i].partyid = new Lookup();
    ap[i].partyid.type = EntityName.systemuser.ToString();
    ap[i].partyid.Value = new Guid(memberID);
    i++;
    }
    
    // specify to part of the email
    emailCreate.to = ap;
    
    // specify the from part of the email
    activityparty from = new activityparty();
    from.partyid = new Lookup();
    from.partyid.type = EntityName.systemuser.ToString();
    from.partyid.Value = new Guid(userID);
    emailCreate.from = new activityparty[] { from };
    
    // finally create the email and get the guid of the email
    Guid emailId = crmService.Create(emailCreate);
    
    // FOR CRM 3.0
    // Specify the system user who is sending the message.
    //crmService.CallerIdValue = new CallerId();
    //crmService.CallerIdValue.CallerGuid = new Guid(userID);
    //
    
    // Create an SendEmailRequest object
    SendEmailRequest req = new SendEmailRequest();
    req.EmailId = emailId;
    req.TrackingToken = “”;
    req.IssueSend = true;
    
    // Finally Send the email message.
    SendEmailResponse res = (SendEmailResponse)crmService.Execute(req);
    }
    Regards,
    Nishant Rana
    http://nishantrana.wordpress.com
    Monday, April 27, 2009 7:31 AM
  • Hi Nishant Rana my members got from Picklist so how could i convert Picklist to Array ?


    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Monday, April 27, 2009 7:47 AM
  • Hi,
    In case of ActivityParty you need to use the guid of the user. Within your picklist, if you are getting the name of the user, first find out their guid's, add all those guid's in the arraylist and pass that arraylist to the above function !!
    This is one way of approaching it !

    Regards,
    Nishant Rana

    http://nishantrana.wordpress.com
    Monday, April 27, 2009 7:54 AM