How to edit "Send to Mail Recipient" on Windows Xp or Windows 7

0

The client I'm using is Windows Live Mail. Desired outcome:

  1. User right clicks on a file and selects "Send To->Mail Recipient" (or another custom created shortcut).
  2. Windows Live Mail New Message window pops out and it contains:

    To: specific email address
    Subject: (empty)
    Body: (empty)
    Clicked file is attached

The closest I got is creating shortcut in Send To folder with such target: C:\Program Files\Windows Live\Mail\wlmail.exe" /mailurl:mailto:123@live.com.

The outcome is that the Windows Live Mail New Message window pops out and it contains:

To: 123@live.com "C:\somefile.txt"
Subject: (empty)
Body: (empty)

Almost right except, the selected file is not attached! It's only mentioned in To: field. How can I get it attached, while also filling in the To: field automatically?

EDIT: "Note that you cannot attach files from the command line" it means that it's very difficult at least.

Maciej Szpakowski

Posted 2014-07-08T17:05:37.397

Reputation: 141

Is WLM set as the default email program? – CharlieRB – 2014-07-08T18:03:54.120

Yes, when i click send to->recipient mail it works normally but there is some bs in body and subjects is always set as Emailing: file – Maciej Szpakowski – 2014-07-08T18:17:29.803

Answers

0

Unfortunately there may be no good way to do this, but below is an AutoHotKey script that mostly gets the job done. An overview of AutoHotKey from Wikipedia is here.

This script was tested on Windows 7 with Windows Live Mail 2012. While most of the beginning portions of the script (up to Run) are generic, the rest is specific and likely will require changes if another gui email program (e.g. Outlook 365, Thunderbird, etc.) is used.

Expectations

The script was written with the following in mind...

  • AutoHotKey is installed on the PC executing the script. If you would like to turn the script into a stand-alone executable, check out ahk2exe.

  • The script expects a single AutoHotKey script command line parameter -- an email address. This allows one script to handle (potentially) different email addresses.

    In order to pass an address, a link for each potential address should be created as follows:

    "C:\Path\To\AutoHotkey\AutoHotkey.exe" "C:\Path\To\Script.ahk" someone@somewhere.com

  • For the sake of uniform action and using command line parameters (which increase script reliability), the script kills then restarts wlmail.exe. So if your are working with Windows Live Mail already, save your work before running it!

  • The script uses the clipboard. Therefore, you should Control+C the item you wish to attach before running the script.

Known Issues

Unfortunately, I'm not a AutoHotKey Ninja so this script may not be perfect. ;-)

However, after a couple days of testing, the script below was reliable at least 99% of the time.

  • It is possible you may experience timing issues occasionally that cause the F10 keystroke in the script not to be recognized by Windows Live Mail.

    This is mostly because Windows Live Mail is lacking in more reliable methods of automation (i.e. no command line attachment, non-standard ribbon interface, and no hot key combo for attaching files).

  • If the "Scheduled Tasks" window appears, this may throw things off as well.

  • If the path from the clipboard isn't valid, you may have to manually terminate the script (see below).

Finally, be aware that if the actions of the script are interrupted (you don't get to a point where Windows Live Mail opens and the item you want is automatically attached), you should look at the Quick Launch area and make sure to shut down that instance of script if necessary before trying again.

AutoHotKey Script to Automate Attachements In Windows Live Mail

Use: Copy an item to the clipboard (Control+C is easiest), then click the link that starts the script (which also should pass the name of the recipient as a command line parameter.)

The script text below should be copy/pasted in its entirety into a standard .txt file and renamed with the .ahk (AutoHotKey script) extension.

; -- 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

Anaksunaman

Posted 2014-07-08T17:05:37.397

Reputation: 9 278

"Couple days of testing" ? Wow thx, I review it tomorrow to see if it's valid. Didn't think about AHK before, but it might the only solution. Programming MAPI got me nowhere :( – Maciej Szpakowski – 2014-07-14T04:24:05.897

Well... couple of lazy days :-) But yeah, I probably would have tried something like MAPI as well, but WLM just seems... unsuited in this case. :-/ – Anaksunaman – 2014-07-15T23:35:27.130

@Maciej Szpakowski I'm not sure if it would fit the bill since your post specified Windows Live Mail, but you may want to check these CDO-based AHK scripts for mailing if your are interested in using some MAPI related stuff. Both have attachment interfaces/paths -- http://www.autohotkey.com/board/topic/36522-cdo-com-email-delivery/ and http://www.autohotkey.com/board/topic/60813-cdo-com-email-delivery-ahk-l/

– Anaksunaman – 2014-07-15T23:49:49.433