by
0
6
151k
0
Top 1% !
Popular
Pearl of Wisdom
Easy-to-find
Specified
OpenSource
Popularity: 12637th place

Published on:

LanguageCSharp
LicenseMIT_X11
MethodNameCreateContactStore
OSWindows
OutputTypevoid

CreateContactStore: Creates a contact store and add contacts.

<summary>
Creates a contact store and add contacts.
</summary>
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/294008/CreateContactStore--Creates-a-contact-st?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
using System; using System.Collections.Generic; using Windows.Phone.PersonalInformation; /// <summary> /// Creates a contact store and add contacts. /// </summary> public static async void CreateContactStore() { ContactStore contactStore = await ContactStore.CreateOrOpenAsync( ContactStoreSystemAccessMode.ReadWrite, ContactStoreApplicationAccessMode.ReadOnly); foreach (SampleContact sampleContact in SampleContact.CreateSampleContacts()) { StoredContact contact = new StoredContact(contactStore); IDictionary<string, object> props = await contact.GetPropertiesAsync(); if (!string.IsNullOrEmpty(sampleContact.FirstName)) { props.Add(KnownContactProperties.GivenName, sampleContact.FirstName); } if (!string.IsNullOrEmpty(sampleContact.LastName)) { props.Add(KnownContactProperties.FamilyName, sampleContact.LastName); } if (!string.IsNullOrEmpty(sampleContact.HomeEmail)) { props.Add(KnownContactProperties.Email, sampleContact.HomeEmail); } if (!string.IsNullOrEmpty(sampleContact.WorkEmail)) { props.Add(KnownContactProperties.WorkEmail, sampleContact.WorkEmail); } if (!string.IsNullOrEmpty(sampleContact.HomePhone)) { props.Add(KnownContactProperties.Telephone, sampleContact.HomePhone); } if (!string.IsNullOrEmpty(sampleContact.WorkPhone)) { props.Add(KnownContactProperties.CompanyTelephone, sampleContact.WorkPhone); } if (!string.IsNullOrEmpty(sampleContact.MobilePhone)) { props.Add(KnownContactProperties.MobileTelephone, sampleContact.MobilePhone); } await contact.SaveAsync(); } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus