抱歉我的英语很差...我尝试使用 Google Apps Script - Contacts Service 阅读我的联系人中的信息。
姓名、电子邮件、地址、电话没有问题,但我无法读取日期(我想获取联系人的出生日期)。如何阅读“日期字段”?
for (var i=0; i<contacts.length; i++) {
Name = contacts[i].getFullName();
EmailArray = contacts[i].getEmails(ContactsApp.Field.HOME_EMAIL);
if (EmailArray.length)
Email = contacts[i].getEmails(ContactsApp.Field.HOME_EMAIL)[0].getAddress();
if (!Email){
EmailArray = contacts[i].getEmails(ContactsApp.Field.WORK_EMAIL);
if (EmailArray.length)
Email = contacts[i].getEmails(ContactsApp.Field.WORK_EMAIL)[0].getAddress();
}
AddressArray = contacts[i].getAddresses(ContactsApp.Field.HOME_ADDRESS);
for ( var j = 0; j < AddressArray.length; j++ ) {
Address = AddressArray[j].getAddress();
AddressSplit = Address.split(/\r\n|\r|\n/);
Rue = AddressSplit[0];
Code = AddressSplit[1].split(" ")[0];
Ville = AddressSplit[1].split(" ")[1];
}
var HomePhone = contacts[i].getHomePhone();
var MobilePhone = contacts[i].getMobilePhone();
//HERE IS THE PROBLEM
DatesArray = contacts[i].getDates();
// Never pass here... How to read the DateField ?
for ( var j = 0; j < DatesArray.lenght; j++ ) {
var date = contacts[i].getDates()[j];
var day = date.getDay();
var month = date.getMonth();
var year = date.getYear();
}
}