title: How to add required attendees in appoitment in microsoft crm
body: <p>I added a new contact in microsoft dynamics 4.0 from C#. How to required attendees from code? I created a contact like this. now how to add this contact as required attendees for selected appointment ?</p>
  
  <pre><code>        CRM.CrmService service = GetService();
  
          var contactResult = new contact
          {
              emailaddress1 = userContact.Email
          };
  
          var requestContact = new RetrieveDuplicatesRequest
          {
              BusinessEntity = contactResult
              ,
              MatchingEntityName = EntityName.contact.ToString()
              ,
              PagingInfo = new PagingInfo
                               {
                                   PageNumber = 1,
                                   Count = 1
                               }
          };
  
          bool blnEmailExists = false;
  
          try
          {
  
  
              var response = (RetrieveDuplicatesResponse)
                                      service.Execute(requestContact);
  
              foreach (contact contactItem in response.DuplicateCollection.BusinessEntities)
              {
                  blnEmailExists = true;
                  contactResult.contactid = new Key();
                  contactResult.contactid.Value = new Guid(contactItem.contactid.Value.ToString());
                  contactResult.firstname = userContact.FirstName;
                  contactResult.lastname = userContact.LastName;
                  contactResult.fullname = userContact.FullName;
                  contactResult.mobilephone = userContact.PhoneNumber;
                  contactResult.description = userContact.Description;
  
                  service.Update(contactResult);
              }
  
              if (!blnEmailExists)
              {
                  contactResult.firstname = userContact.FirstName;
                  contactResult.lastname = userContact.LastName;
                  contactResult.fullname = userContact.FullName;
                  contactResult.mobilephone = userContact.PhoneNumber;
                  contactResult.description = userContact.Description;
  
  
                  Guid contactId = service.Create(contactResult);
  
                  if (!string.IsNullOrEmpty(userContact.Notes))
                      AppendToNotesSection(userContact.Notes, contactId, service);
              }
          }
          catch (System.Web.Services.Protocols.SoapException ex)
          {
              throw new Exception(ex.Message);
          }
  </code></pre>
  
  <p>Thanks</p>