(Google Script新增{约2周}所以请详细说明)
我已尝试过我能找到或想到的所有内容,以显示联系人电子邮件地址列表的自定义标签。这非常令人沮丧。当我搜索时,我获得了很多针对gmail消息标签的点击,但没有针对单个联系人中的电子邮件地址的自定义标签。
长期目标是为我儿子的童子军部队建立一个汽车运输代理商,采取婴儿步骤到达那里。
有些男孩希望通过短信通知,有些通过电子邮件通知。由于一些人有实际的电子邮件(用于附件)和手机(用于提醒),因此需要自定义联系电子邮件标签。我可以列出所有联系人组,我可以列出每个组中的所有联系人姓名。我甚至可以获得每个联系人的所有电子邮件地址。但我无法获得联系人电子邮件列表的自定义标签。
为什么“getLabel”方法无法完成所有“幕后”工作并返回标签文本,无论标签类型如何(自定义或内置),都超出了我的范围。
任何指导都将不胜感激。
function Get_Groups_Contacts(GroupList)
{
var groups = ContactsApp.getContactGroups(); //get the list of groups
for (var i in groups) //for each item in the group list ...
{
for (var n=0; n<=15; n++) //need to setup retries since the next part sometimes has server issues
{
try //trap errors
{
var cont = groups[i].getContacts() //get the list of contacts that belong to the group
var arrCont= [] //define the temp storage
for (var j in cont) //step through each contact
{
//I can store a list of contact names…
arrCont.push(cont[j].getFullName() ); //get the contact's full name
// but am trying to switch to specific email address….
var eml = cont[j].getEmails(); // the list of all email address for a contact
//now the messy part, trying to figure things out
//lists the built in labels but not the custom labels
for (k in eml) Logger.log(typeof eml[k].getLabel() + "??" + eml[k].getLabel() + "--" + eml[k].getAddress());
for (k in eml)
{
try
{
var x = eml[k].getLabel();
Logger.log(k + " !!" + typeof x + "??" + x + "--" + eml[k].getAddress() + "**" + "hello");
// var oneeml = eml[k];
var oneeml = cont[j].getEmails("Other");
Logger.log("xxxxxxxxxxxxxxxxxxxxxxxx");
Logger.log("oneeml " + oneeml);
//Logger.log(oneeml.getLabel())
Logger.log("zzzzzzzzzzzzzzzzzzzzzzzz");
for (zz in oneeml) Logger.log(oneeml[zz]);
for (zz in oneeml)
if (zz == "setAsPrimary") Logger.log(zz)
else if (zz == "setDisplayName") Logger.log(zz)
else if (zz == "setAddress") Logger.log(zz)
else if (zz == "setLabel") Logger.log(zz)
else if (zz == "deleteEmailField") Logger.log(zz)
else Logger.log(oneeml[zz]())
;
}
catch(ext)
{
Logger.log("inner catch");
Logger.log(ext.message);
}
}
}
//end of the messy part
GroupList[groups[i].getGroupName()] = arrCont //store the list in the property
break; //go on to the next group
} //end of try
catch(err) //catch the error here
{
// Logger.log (n + " error message" + err.message); //debug
Logger.log ("n=" + n); //debug
sleep((Math.pow(2,n) + (Math.random(0, 1000) / 100)) ); //increasing random sleep time waiting for the server
} //end of catch
finally //always do this part
{
cont = undefined; //cleanup
arrCont = undefined; //cleanup
} //end of error traping
} //end of retry loop
} //end for each group item
}; //end of function List_Groups_Contacts()