2017-11-16 3 views
0

メッセージの件名をExcelワークシートにエクスポートするApplescript for Mail.appを作成する必要があります。AppleScriptでMail.appのImapフォルダからメッセージを選択

私はこれを行うことができ、オンラインで見つけたクローゼットのコードは、次のとおりです。

tell application "Microsoft Excel" 
set theSpamFile to make new workbook 
set theSheet to active sheet of theSpamFile 
set formula of range "B1" of theSheet to "Subject" 
set formula of range "A1" of theSheet to "From" 
end tell 
tell application "Mail" 
set theRow to 2 
get mailboxes 
set theMessages to messages of junk mailbox 
repeat with aMessage in theMessages 
my SetFrom(sender of aMessage, theRow, theSheet) 
my SetSubject(subject of aMessage, theRow, theSheet) 
set theRow to theRow + 1 
end repeat 
end tell 

on SetFrom(theSender, theRow, theSheet) 
tell application "Microsoft Excel" 
set theRange to "A" & theRow 
set formula of (range theRange) of theSheet to theSender 
end tell 
end SetFrom 

on SetSubject(theSubject, theRow, theSheet) 
tell application "Microsoft Excel" 
set theRange to "B" & theRow 
set formula of range theRange of theSheet to theSubject 
end tell 
end SetSubject 

メールボックスジャンクのためのこれらのコードの作業罰金。

しかし、Mail.appのImapアカウントのサブフォルダ内のメッセージを選択するコードを操作する方法はわかりません。

私はMail.appにいくつかのImapアカウントを持っています。 2つのgmailアカウント、1つのiCloudアカウントなど。私はまた、各Imapアカウントの下にフォールドとサブフォルダを作成しました。

私はサブフォルダからの未読メッセージをエクスポートする:それは私が

set theMessages to messages of junk mailbox 

から選択線を変更しようとしました

「グーグル/サプライヤー/ SupplierUpdate」に位置しています

set theMessages to messages of mailbox"[Google]/DobaSupplierUpdate/DobaCancellation" 

スクリプトエディタでは、次のメッセージが表示され続けます。

Mail got an error: Can’t get mailbox "[Google]/DobaSupplierUpdate/DobaCancellation". 

正しい方向で私を指摘する助けがありますか?

答えて

0

はこのような何か試してみてください:

-- set your email address here to find your account 
set targetAccount to first item of (every account whose user name is "[email protected]") 
-- define the wanted subfolders here starting with deepest level 
set theMessages to every message of mailbox "SupplierUpdate" of mailbox "Supplier" of targetAccount whose read status is false 

ベストを、 ShooTerKo /ハンブルク

+0

@Iviciアン未解決の問題は未解決の問題です。回答が必要ない場合は、ソリューションを投稿しなかったのはなぜですか? – ShooTerKo

+0

あなたの答えは本当に素晴らしいです!私はあなたが私にあなたのコードを与えたとしても圧倒されたと告白する必要があります。私はAppleScriptの新機能です。だから、私はそれらをアソシエートコード行で置き換えるために何度も試してきました。ついにできた。本当に助けに感謝します。これは私の毎日の仕事をより速く改善するでしょう。最高 – Ivici

+0

私はどのように電子メールメッセージの「主題」から特定の部分を正確に入れることができますか?たとえば、件名はすべて「UNFIからの注文1422474のトラッキング情報」のようなものです。私が必要とするのは、数字の部分 "1422474"だけです。 Excelスプレッドシートに入力する前に、どのようにしてそれを抽出することができますか? – Ivici

関連する問題