3

(Google 脚本的新手{大约 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()
4

0 回答 0