# Assign Contacts to an Appointment

## Content



Assigning a contact or contacts to an appointment can be done either through the **Contacts** dialog box at runtime or programmatically. For information on how to add items, see [Add Contacts to the Contacts List](/componentone/docs/wpf/online-scheduler/Appointments/Contacts/Adding_Contacts_to_the_Contacts_List).

The contact appears next in the **Contacts** text box as shown in the following image.

![Assign Contact in WPF Scheduler Appointment dialog](https://cdn.mescius.io/document-site-files/images/4c5f07fe-a0aa-4d09-95ef-6685908019cd/graphics/addcontacttoappointment.png)

To assign a contact to an appointment at run time, follow these steps:

1.  Click the **Contacts** button in the **Appointment** dialog box.
2.  Select the check box next to the desired contacts and click **Ok**.<br />![Contacts dialog in WPF Scheduler](https://cdn.mescius.io/document-site-files/images/4c5f07fe-a0aa-4d09-95ef-6685908019cd/images/assigncontact.png)

To assign contacts to an appointment programmatically, use the following code:

```csharp
//Create Appointments
Appointment app = new Appointment(DateTime.Now.Date,DateTime.Now.Date.AddDays(1));
app.Subject = "Meeting";
sched1.DataStorage.AppointmentStorage.Appointments.Add(app);
//Add contacts to the ContactList
sched1.DataStorage.ContactStorage.Contacts.Add(new Contact() { MenuCaption =  "Lionel Messi" });
sched1.DataStorage.ContactStorage.Contacts.Add(new Contact() { MenuCaption = "Cristiano Ronaldo" });
sched1.DataStorage.ContactStorage.Contacts.Add(new Contact() { MenuCaption = "Xavi" });
sched1.DataStorage.ContactStorage.Contacts.Add(new Contact() { MenuCaption = "Andres Iniesta" });
sched1.DataStorage.ContactStorage.Contacts.Add(new Contact() { MenuCaption = "Zlatan Ibrahimovic" });
sched1.DataStorage.ContactStorage.Contacts.Add(new Contact() { MenuCaption = "Radamel Falcao" });
sched1.DataStorage.ContactStorage.Contacts.Add(new Contact() { MenuCaption = "Robin van Persie" });
sched1.DataStorage.ContactStorage.Contacts.Add(new Contact() { MenuCaption = "Andrea Pirlo" });
sched1.DataStorage.ContactStorage.Contacts.Add(new Contact() { MenuCaption = "aya Toure" });
sched1.DataStorage.ContactStorage.Contacts.Add(new Contact() { MenuCaption = "Edinson Cavani" });
var appointment = sched1.DataStorage.AppointmentStorage.Appointments.First(x => x.Start == DateTime.Now.Date);
var contactList = sched1.DataStorage.ContactStorage.Contacts;
appointment.Links.Add(contactList.First(x => x.MenuCaption == "Cristiano Ronaldo"));
appointment.Links.Add(contactList.First(x => x.MenuCaption == "Lionel Messi"));
```