We have moved to a new Sailfish OS Forum. Please start new discussions there.
3

How to read an email address from a Person of PeopleModel?

asked 2019-02-24 19:06:52 +0300

jsommer gravatar image

updated 2019-02-24 19:08:20 +0300

The documentation of the nemo-qml-plugin-contacts suggests, that the emailDetails of a Person are returned as a QVariantList. Unfortunately I couldn't manage to get the email addresses. A similar challange is to get the phone numbers.

I have looked at the EmailEditor.qml and MultiTypeFieldEditor.qml of the default Sailfish email app. The value field of the QVariant object in the QVariantList seems to be "address", but I always get "undifiend" in the log. Here are some trials:

var contact = contacts.personById(contactIdentifier)
for (var emailDetails in contact.emailDetails) {
    console.log("- " + emailDetails['address'])
    console.log("- " + emailDetails.address)
    console.log("- " + emailDetails.value)
    console.log("- " + emailDetails.label)
}

The toString() method returns just the index of the QVariant object.

Has someone an idea?

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
5

answered 2019-02-25 01:05:31 +0300

jsommer gravatar image

The solution was easy:

var contact = contacts.personById(contactIdentifier
var emailDetails = contact.emailDetails
for (var i = 0; i < emailDetails.length; i++) {
    console.log("Entry " + emailDetails[i].address)
}
edit flag offensive delete publish link more

Comments

2

@jsommer Could you please accept this answer and close the question as answered? By the way, thank you for sharing your programming problems and solutions here.

Maus ( 2019-02-25 11:16:05 +0300 )edit
Login/Signup to Answer

Question tools

Follow
3 followers

Stats

Asked: 2019-02-24 19:06:52 +0300

Seen: 205 times

Last updated: Feb 25 '19