teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

修正

2021/11/13 14:05

投稿

退会済みユーザー
answer CHANGED
@@ -39,11 +39,13 @@
39
39
  const attachments = message.getAttachments();
40
40
  const mailAddress = message.getFrom().replace(/^.+<([^>]+)>$/, '$1');
41
41
  const contacts = ContactsApp.getContactsByEmailAddress(mailAddress);
42
- const name = contacts[0].getFullName();
42
+ const name = contacts[0].getFullName()
43
43
 
44
44
  for(const attachment of attachments){
45
- folder.createFile(attachment).setName(name);
45
+ const file = folder.createFile(attachment);
46
+ const newFileName = '[送信者名:' + name + ']' + file.getName();
47
+ file.setName(newFileName);
46
- Logger.log('ファイル名「' + name + '」をフォルダに作成しました。')
48
+ Logger.log('ファイル名「' + newFileName + '」をフォルダに作成しました。')
47
49
  }
48
50
  }
49
51
  }