Created
May 12, 2015 10:15
-
-
Save y16ra/b77fa37fe503b11a0a97 to your computer and use it in GitHub Desktop.
JXA(Javascript for Automation)で添付ファイルを保存する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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