写入我的联系人 [英] Writing into My Contacts
问题描述
我一直在尝试在我的联系人"文件夹中创建联系人,因此可以将其与我的手机同步.我不介意使用群组,但是在iPhone上它们的同步已中断.无论如何,我正在使用此脚本:
I have been trying to create contact in My Contacts folder, so it could be synced with my phone. I would't mind using groups, but their synchronization is broken on iPhone. Anyway, I am using this script:
function update() {
var group = ContactsApp.findContactGroup('My Contacts');
group.addContact(ContactsApp.createContact('Fido','McDog', 'fido@example.com'));
var contact = ContactsApp.findByEmailAddress('fido@example.com');
contact.setWorkPhone('123123123123');
}
如果我对我的联系人"使用任何其他名称,则脚本可以完美运行.否则会出现错误:TypeError:无法调用null的方法"addContact".(第3行)
If I use any other name for 'My Contacts', the script works perfectly. Otherwise I get error: TypeError: Cannot call method "addContact" of null. (line 3)
是Google的某种限制吗?
Is that some sort of limitation from Google?
谢谢.
推荐答案
看来,我的联系人"组实际上称为系统组:我的联系人".其他系统组的命名也类似,以便添加到我的联系人"而不是其他..."中.
It appears that the Group My Contacts is actually called "System Group: My Contacts". Other system groups are similarly named so, to add to My Contacts rather than Other ...
function test() {
var group = ContactsApp.getContactGroup("System Group: My Contacts");
group.addContact(ContactsApp.createContact('Fido','McDog', 'fido@example.com'));
var contact = ContactsApp.findByEmailAddress('fido@example.com');
contact.setWorkPhone('123123123123');
}
这篇关于写入我的联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!