Skip to content

Instantly share code, notes, and snippets.

@y16ra
Created May 12, 2015 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y16ra/b77fa37fe503b11a0a97 to your computer and use it in GitHub Desktop.
Save y16ra/b77fa37fe503b11a0a97 to your computer and use it in GitHub Desktop.
JXA(Javascript for Automation)で添付ファイルを保存する
var Mail = Application("Mail");
Mail.includeStandardAdditions = true;
// 選択したメッセージを取得
var messages = Mail.selection();
for (i = 0; i < messages.length; i++) {
var thisMessage = messages[i];
// メッセージに添付されたファイルを取得しhogehogeユーザホームに保存する
var atFiles = thisMessage.mailAttachments();
for (j=0; j<atFiles.length; j++){
var thisFile = atFiles[j];
var path = new Path("/Users/hogehoge/" + atFiles[j].name());
thisFile.save({in: path})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment