2006年03月07日

[Macintosh] , [Windows] , [仕事術/ライフハック] , [プログラミング]

メールのMessage-Idを一覧表示

メールのMessage-Idを一覧表示させる必要ができたので、そのメモ。
OutlookのVBAにはMessage-Idを直接取得するためのプロパティが用意されていない。何やらCDOを使ってMAPIを呼び出すとか、Redemptionというツールを使う必要があるらしい。Outlook TipsというサイトにMAPIを利用したサンプルが掲載されていた(動作は未確認)。
これに比べて、Mac OS XのMail.appはすごく簡単。Message-IdをAppleScriptから直接取得できる。以下は、Mac OS Xに収録されていたMail.app用サンプルスクリプトをちょこっといじったもの。Mail.app上でメールを選択しスクリプトを実行すると、ダイアログにMessage-Idのリストが表示される(利用は自己責任で)。

using terms from application "Mail"
	on perform mail action with messages selectedMsgs
		-- See Mail's AppleScript dictionary for the full documentation on the
		-- 'perform mail action with messages' handler.
		set logString to ""
		tell application "Mail"
			set selCount to (count of selectedMsgs)
			repeat with counter from 1 to selCount
				set msg to item counter of selectedMsgs
				set theMessageID to "Message-Id: <" & message id of msg & ">"
				set logString to (logString & return & theMessageID)
			end repeat
		end tell
		if length of logString > 0 then
			display dialog "Message-Idのリスト" default answer logString
		end if
	end perform mail action with messages
end using terms from

using terms from application "Mail"
on run
tell application "Mail" to set sel to selection
tell me to perform mail action with messages (sel)
end run
end using terms from

Posted by Tats_y at 2006年03月07日 10:07 | このエントリーを含むはてなブックマーク ブックマークに追加する | この記事へのリンク
この記事へのトラックバック
(※このエントリーに対してトラックバックを送る際は、下記URLをコピーし、自分のエントリーの「TrackBack先のURL」欄に貼り付けてください)



(※この記事へのリンクは、http://www.binword.com/blog/archives/000478.htmlにお願いします。トラックバック用URLとは異なりますのでご注意ください)

以下は、このエントリーに送られたトラックバックです。
この記事に対するコメント
コメントを投稿する









次回投稿するために、あなたのお名前やメールアドレスを記憶しておきますか?




コメントスパム防止のため、画像で表示されている文字を入力してください。