私が使用しているクライアントは Windows Live Mail です。望ましい結果:
ユーザーはファイルを右クリックし、「送信先 -> メール受信者」(またはカスタム作成された別のショートカット) を選択します。
Windows Live メールの新規メッセージ ウィンドウがポップアップ表示され、次の内容が表示されます。
宛先: 特定のメールアドレス
件名: (空)
本文: (空)
クリックしたファイルが添付されています
私が一番近かったのは、次のようなターゲットで「送信先」フォルダーにショートカットを作成することです。C:\Program Files\Windows Live\Mail\wlmail.exe" /mailurl:mailto:[email protected]
その結果、Windows Live メールの新規メッセージ ウィンドウがポップアップ表示され、次の内容が表示されます。
に:[メールアドレス]"C:\somefile.txt"
件名: (空)
本文: (空)
ほぼ正解だが、選択したファイルは添付されていません! To: フィールドにのみ記載されています。自動的にフィールドに入力しながら添付するにはどうすればよいでしょうかTo:
?
編集: 「コマンドラインからファイルを添付することはできないことに注意してください」これは、少なくとも非常に難しいことを意味します。
答え1
残念ながら、これを行う良い方法はないかもしれませんが、以下はオートホットキーほとんど目的を達成できるスクリプト。WikipediaのAutoHotkeyの概要はこちら。
このスクリプトは、Windows Live Mail 2012 を搭載した Windows 7 でテストされました。スクリプトの最初の部分 (までRun
) のほとんどは汎用的ですが、残りの部分は固有のものであり、別の GUI 電子メール プログラム (Outlook 365、Thunderbird など) を使用する場合は変更が必要になる可能性があります。
期待
この脚本は、次の点を念頭に置いて書かれました...
AutoHotkeyはスクリプトを実行するPCにインストールされています。スクリプトをスタンドアロン実行可能ファイルに変換したい場合は、ahk2exe。
スクリプトは単一のAutoHotkey スクリプトのコマンドラインパラメータ— 電子メール アドレス。これにより、1 つのスクリプトで (潜在的に) 異なる電子メール アドレスを処理できるようになります。
アドレスを渡すには、次のように各潜在的なアドレスへのリンクを作成する必要があります。
"C:\Path\To\AutoHotkey\AutoHotkey.exe" "C:\Path\To\Script.ahk" [email protected]
アクションを統一し、コマンド ライン パラメータ (スクリプトの信頼性を高める) を使用するために、スクリプトは強制終了してから再起動します
wlmail.exe
。そのため、既に Windows Live Mail を使用している場合は、実行する前に作業内容を保存してください。スクリプトはクリップボードを使用します。したがって、スクリプトを実行する前に、添付する項目をCtrl+する必要があります。C
既知の問題点
残念ながら、私は AutoHotkey の達人ではないので、このスクリプトは完璧ではないかもしれません。 ;-)
しかし、数日間のテストの後、以下のスクリプトは少なくとも 99% の確率で信頼できるものでした。
- タイミングの問題が発生する可能性があり、F10キーストロークスクリプトでは Windows Live メールによって認識されません。
これは主に、Windows Live メールにはより信頼性の高い自動化の方法が欠けていることが原因です (つまり、コマンド ライン添付、非標準のリボン インターフェイス、ファイル添付用のホット キー コンボがありません)。
「スケジュールされたタスク」ウィンドウが表示された場合も、問題が発生する可能性があります。
クリップボードからのパスが有効でない場合は、スクリプトを手動で終了する必要がある場合があります (以下を参照)。
最後に、スクリプトの動作が中断された場合(Windows Live Mailが開くまで到達しなかった場合)は、欲しいアイテムが自動的に添付されます) の場合は、クイック起動領域を確認し、再試行する前に必要に応じてそのスクリプトのインスタンスをシャットダウンしてください。
Windows Live メールの添付ファイルを自動化する AutoHotkey スクリプト
使用
アイテムをクリップボードにコピーし ( Ctrl+Cが最も簡単です)、スクリプトを開始するリンクをクリックします (受信者の名前もコマンド ライン パラメーターとして渡される必要があります)。
以下のスクリプト テキスト全体を標準.txt
ファイルにコピー/貼り付けし、.ahk
(AutoHotkey スクリプト) 拡張子を付けて名前を変更する必要があります。
; -- Functions & Variables --
; A custom to check if a given processes is active
ProcessExist(Name){
Process,Exist,%Name%
return Errorlevel
}
; -- Begin Script --
; Command line parameter debug box.
;MsgBox, The number of command line parameters is %0%. `n`n The email recipient is %1%
; Check for command line parameters - terminate if we have anything but one.
If 0 <> 1
{
MsgBox, You have not specified a valid email address. Script terminating.
exitapp ; Exit our script
}
; If our clipboard is empty, show a warning
If clipboard =
{
MsgBox, 4, , Please copy your attachment to the clipboard.`n`nContinue?
IfMsgBox, No, exitapp ; Exit our script
}
ClipWait ; Wait for the clipboard to contain text.
;Display the last item copied to the clipboard to confirm this is the item we want.
Loop, parse, clipboard, `n, `r
{
MsgBox, 4, , File number %A_Index% for attachement is located at %A_LoopField%.`n`nEmail recipient is %1%.`n`nContinue?
IfMsgBox, No, exitapp ; Quit the AutoHotkey script if the user says no.
}
; Start with a clean Windows Live Mail instance.
; wlmail.exe may active as a process so we make sure to kill it.
If ProcessExist("wlmail.exe")
Process, Close, wlmail.exe
Sleep 100 ; Make sure the process has time to terminate
; Start a fresh wlmail.exe process to send a new email.
; /mailurl:mailto: is part of the wlmail.exe command line options.
Run, "C:\Program Files (x86)\Windows Live\Mail\wlmail.exe" /mailurl:mailto:%1%
; Make sure our New Message window is active
WinWait, New Message,
IfWinNotActive, New Message, , WinActivate, New Message,
WinWaitActive, New Message,
; If the script is going to fail, it will be between the TAB TAB F10 4 strokes.
; Double TAB brings us to the body of the message. Otherwise, the address field is the first active
; item and F10 brings up a different menu.
Send, {TAB} {TAB}
; Show the attachment dialog via pressing F10 then 4.
; Increase the Sleep value for better key stroke reliability -- 5000+ recommended.
; Otherwise, Windows Live Mail seems to "miss" the F10 stroke.
Sleep 5000
Send, {F10}
Send, 4
; Make sure our Open file dialog is active
WinWait, Open,
IfWinNotActive, Open, , WinActivate, Open,
WinWaitActive, Open,
; Copy our file path from the clipboard and open it
Send, {CTRLDOWN}v{CTRLUP}
Sleep 1000
Send {TAB}{TAB}{Enter}
exitapp ; Exit our script