Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

CNContact.AddInstantMessage

Adds an instant message account to a contact.

Component Version macOS Windows Linux Server iOS SDK
Contacts 8.4 ✅ Yes ❌ No ❌ No ❌ No ✅ Yes
MBS( "CNContact.AddInstantMessage"; ContactIdentifier; Name; Service { ; Label } )   More

Parameters

Parameter Description Example Flags
ContactIdentifier The contact identifier. "46B1E34D-58F9-4B6B-A80D-0F71ABB87A0E"
Name The name of the account. "Test"
Service The service for this account.
We translate AIM, Facebook, GaduGadu, GoogleTalk, ICQ, Jabber, MSN, QQ, Skype and Yahoo to the right constant for you.
"Facebook"
Label The label to use.
For your convenience we translate Work, Home and Other to the right values, so they get localized in display.
Default label is Other.
"Work" Optional

Result

Returns OK or error.

Description

Adds an instant message account to a contact.
This is a convenience function to add just one instant message account with a given label to the contact.
Please call CNContactStore.UpdateContact later to store the values.

Examples

Create contact:

Set Variable [ $contactID ; Value: MBS( "CNContactStore.NewContact") ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "givenName"; "Joe" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "familyName"; "Miller" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "jobTitle"; "Family Manager" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "organization"; "Family" ) ]
#
#
Set Variable [ $image ; Value: MBS( "Container.ReadFile"; "/Library/Desktop Pictures/Lion.jpg") ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "imageData"; $image ) ]
#
Set Variable [ $r ; Value: MBS( "CNContact.AddEmailAddress"; $contactID; "test@test.test"; "Work" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddInstantMessage"; $contactID; "instantTest"; "Facebook"; "Work" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddURLAddress"; $contactID; "http://www.monkeybreadsoftware.com/"; "Homepage" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddSocialProfile"; $contactID; "Home"; "http://www.facebook.com"; "testSocial"; ""; "Facebook" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddRelation"; $contactID; "Jane Miller"; "Sister" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddPhoneNumber"; $contactID; "123 456 789"; "iPhone" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddPostalAddress"; $contactID; "Home"; "Main Street 123"; "New City"; "NS"; "12345"; "USA"; "US" ) ]
#
Set Variable [ $contactID ; Value: MBS( "CNContactStore.AddContact"; $contactID) ]
If [ MBS("IsError") ]
    Show Custom Dialog [ "Failed to create a contact" ; $r ]
Else
    Set Field [ Contacts::ContactID ; $contactID ]
    Set Variable [ $json ; Value: MBS( "CNContact.JSON"; $contactID) ]
    Set Variable [ $json ; Value: MBS("JSON.Colorize"; MBS( "JSON.Format"; $json) ) ]
    Set Field [ Contacts::Result ; $json ]
End If

See also

Example Databases

Created 1st August 2018, last changed 13th January 2021


CNContact.AddEmailAddress - CNContact.AddInstantMessageJSON

💬 Ask a question or report a problem