| Arguments : |
| name | Type | 説明 |
|
firstName | String |
連絡先の名 |
|
lastName | String |
連絡先の姓 |
|
emailAddress | String |
連絡先のメールアドレス |
| 戻り値 : |
| Type | 説明 |
|
Contact |
新しく作られた連絡先オブジェクト
|
| Googleのサンプル : |
var c = ContactsApp.createContact('Fido','McDog', 'fido@example.com');
var contact = ContactsApp.findByEmailAddress('fido@example.com');
Browser.msgBox (contact.getFullName());
|
| 動作確認用サンプル : |
// 新規連絡先を作成して、そのフルネームを取得表示
// 新規(指定グループなし)で作成した連絡先(Gamil内)は”その他の連絡先”に作成される
// first name, last nameは両方必須
function createContact() {
var c = ContactsApp.createContact('Gmail','連絡先', 'test@example.com');
var contact = ContactsApp.findByEmailAddress('test@example.com');
Browser.msgBox (contact.getFullName());
}
|
20101025
| Arguments : |
| name | Type | 説明 |
|
name | String |
作成する連絡先グループの名前 |
| Googleのサンプル : |
var group = ContactsApp.createContactGroup("Pets");
group.addContact(ContactsApp.createContact('Fido','McDog', 'fido@example.com'));
|
| 動作確認用サンプル : |
// 連絡先に"My Group"グループを作成して
// スプレッドシートから一名をグループに追加
function createContactGroup(){
var mysheet = SpreadsheetApp.getActiveSheet();
var gname = mysheet.getRange("D2").getValue();
var name1 = mysheet.getRange("A2").getValue();
var name2 = mysheet.getRange("B2").getValue();
var ad = mysheet.getRange("C2").getValue();
var group = ContactsApp.createContactGroup(gname);
group.addContact(ContactsApp.createContact(name1,name2,ad));
}
|
使用したスプレッドシート;
実行結果;
|
20101110
| Arguments : |
| name | Type | 説明 |
|
contact | Contact |
作成する連絡先グループの名前 |
| Googleのサンプル : |
var contact = ContactsApp.findByEmailAddress('fido@example.com');
contact.deleteContact();
|
| 動作確認用サンプル : |
//所属グループに関係なく指定メールアドレスの連絡先を削除する
function deleteContact(){
var contact = ContactsApp.findByEmailAddress('test@example.com');
contact.deleteContact();
}
|
20101213
| サンプル : |
var group = ContactsApp.createContactGroup("Pets");
group.addContact(ContactsApp.createContact('Fido','McDog', 'fido@example.com'));
ContactsApp.deleteContactGroup(group);
|
method findbyEmailAddress(address)
| Arguments : |
| name | Type | 説明 |
|
address | String |
探すべき連絡先のメールアドレス |
| Googleのサンプル : |
var contact = ContactsApp.findByEmailAddress('fido@example.com');
Browser.msgBox (contact.getFullName());
|
| 動作確認用サンプル : |
// 指定アドレスによって連絡先名を検索し表示する
//このアドレス誰だったけ?なんてときとか、メールの宛先に流し込んだり。。いろいろ活用できそう。
function findByEmailAddress(){
var contact = ContactsApp.findByEmailAddress('test@example.com');
Browser.msgBox (contact.getFullName());
}
|
20101213
| Arguments : |
| name | Type | 説明 |
|
name | String |
探すべき連絡先グループの名前 |
| Googleのサンプル : |
var group = ContactsApp.findContactGroup("Pets");
|
| 動作確認用サンプル1 : |
// "TEST2"というグループ名を検索し見つからない時は表示
function findGroup(){
var target = "TEST2";
var findby = ContactsApp.findContactGroup(target);
if(findby == null){
Browser.msgBox ("連絡先グループ" + target + "はありません。");
}
}
|
| 動作確認用サンプル2 : |
//連絡先グループを抽出し、新規の連絡先を追加する
function findContactGroup2(){
var findby = ContactsApp.findContactGroup("TEST");
var contact = ContactsApp.createContact('新規','連絡先', 'new@example.com');
contact.addToGroup(findby);
Browser.msgBox ("新しい連絡先を追加しました。");
}
|
| 動作確認用サンプル3 : |
//インプットボックスに検索対象グループ名を入力させる
//見つからない場合は新規作成のためのグループ名を入力するように指示する
//グループを作成して新規の連絡先を追加(ここもインプットボックスで入力させると良いでしょうね)
function findElse(){
var target = Browser.inputBox("連絡先グループを検索します。グループ名を入力してください。",Browser.Buttons.OK_CANCEL);
var findby = ContactsApp.findContactGroup(target);
if(findby == null){
Browser.msgBox ("連絡先グループ" + target + "はありません。");
var newGrp = Browser.inputBox("新規連絡先グループを作成します。グループ名を入力してください。",
Browser.Buttons.OK_CANCEL);
var group = ContactsApp.createContactGroup(newGrp);
group.addContact(ContactsApp.createContact('Mr.','New', 'add@example.com'));
}
else{
Browser.msgBox ("連絡先グループ" + target + "が見つかりました。"); //検索対象グループ名が見つかった時の表示
}
}
|
20101213
| Googleのサンプル : |
var contacts = ContactsApp.getAllContacts();
for (var i in contacts) {
var contact = contacts[i];
var name = contact.getFullName();
Browser.msgBox(name);
}
|
| 動作確認用サンプル : |
// すべての連絡先をlogに出力
function getAllContacts() {
var contacts = ContactsApp.getAllContacts();
for (var i in contacts) {
var contact = contacts[i];
var name = contact.getFullName();
Logger.log (name);
}
}
|
|
20110127
-
ContactsApp内の連絡先グループの完全なリストを取得する
ContactsAppには連絡先のリストのみならず潜在的に連絡先グループのリストも含まれている。各連絡先グループは連絡先を持つことができる。
このメソッドはすべての連絡先グループのリストを返す。
| 戻り値 : |
| Type | 説明 |
|
ContactGroups[ ] |
すべての連絡先グループ
|
| Googleのサンプル : |
var groups = ContactsApp.getContactGroups();
for (var i in groups)
Logger.log (groups[i].getGroupName());
|
| 動作確認用サンプル : |
// すべての連絡先グループをlogに出力
function getContactGroups() {
var groups = ContactsApp.getContactGroups();
for (var i in groups) {
Logger.log (groups[i].getGroupName());
}
}
|
|
20110127
|