Add Send to E-Mail Recipient to Tool Bar

Discuss and share scripts and script files...
IMPVGO
Posts: 9
Joined: 16 May 2011 02:48

Add Send to E-Mail Recipient to Tool Bar

Post by IMPVGO »

What would be a script to add Send selected file(s) to E-Mail recipient utilizing default mail client to the the Tool Bar on XYplorer?. The newly created e-mail should contain the name of the attached file(s) in the "subject" of the e-mail and in the "body" of it. I will really appreciate help in this regard.

Impvgo
Last edited by IMPVGO on 19 May 2011 01:36, edited 2 times in total.

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Add Send to E-Mail Recipient to Tool Bar

Post by Stefan »

IMPVGO wrote:What would be a script to add Send selected file(s) to E-Mail recipient utilizing default mail client to the the Tool Bar on XYplorer?. The newly created e-mail should contain the name of the attached file(s) in the "subject" of the e-mail and in the "body" of it. I will really appreciate help in this regard.

Impvgo
Please post the command line parameters your e-mail client supports:
- path to the exe of your e-mail client
- command line to add text as subject
- command line to add text as body
- command line to add attachments


If you want to do it on your own
see XYplorer help "Advanced Topics > Variables" for vars like
<curitem> current (selected & focused) list item (full path)

and "Advanced Topics > Scripting Commands Reference" for commands like
get("SelectedItemsNames")

- - -

Or check if this defaults works in your XYplorer address bar
::run "mailto:support@xyplorer.com?subject=Wow!&body=Hi!"
Open email client with some fields prefilled.

Find here some more parameters:
http://support.microsoft.com/kb/197782/en-us
In order to create a preformatted and pre-addressed e-mail message,
it is necessary to build a command-line string with the following parameters:
mailto:<to email>?cc=<cc email>&bcc=<bcc
mail>&subject=<subject text>&body=<body text>
Where the following variable definitions apply:

Code: Select all

   Variable                        Field Entry
   --------------------------------------------------------------
   <to e-mail>          e-mail address to appear in the To field
   <cc mail>            e-mail address to appear in the CC field
   <bcc mail>           e-mail address to appear in the BCC field
   <subject>            text to appear in the Subject field
   <body text>          text to appear in the Body of the message
I read also that attachment="C:\path\filename" should work for 0utl00k 2003.
Maybe this works for other clients too?

IMPVGO
Posts: 9
Joined: 16 May 2011 02:48

Re: Add Send to E-Mail Recipient to Tool Bar

Post by IMPVGO »

Thank-you for your reply. With your help, I wrote the following script on a customizable toolbar button:

//Attach to Thunderbird
$items=chr(39).get("SelectedItemsPathNames",",").chr(39);
run """C:\Program Files\Mozilla Thunderbird\Thunderbird.exe"" -compose attachment=$items,
subject=Emailing("SelectedItemsPathNames")
body=("SelectedItemsPathnames";

And when I presss the button, my explorer opens on "computer" location.

Impvgo

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Add Send to E-Mail Recipient to Tool Bar

Post by serendipity »

IMPVGO wrote:Thank-you for your reply. With your help, I wrote the following script on a customizable toolbar button:

//Attach to Thunderbird
$items=chr(39).get("SelectedItemsPathNames",",").chr(39);
run """C:\Program Files\Mozilla Thunderbird\Thunderbird.exe"" -compose attachment=$items,
subject=Emailing("SelectedItemsPathNames")
body=("SelectedItemsPathnames";

And when I presss the button, my explorer opens on "computer" location.
Impvgo
Your script looks very similar to the one i wrote here:
http://www.xyplorer.com/xyfc/viewtopic. ... 620#p55620

I guess you wanted to modify it a bit and include filenames in the subject and body. The part after "subject=" wont work.
Try this instead:

Code: Select all

//Attach to Thunderbird
    $items=chr(39).get("SelectedItemsPathNames",",").chr(39);
    $itemnames=get("SelectedItemsNames",", ");
    run """C:\Program Files\Mozilla Thunderbird\Thunderbird.exe"" -compose attachment=$items, subject=$itemnames, body=$itemnames";	

IMPVGO
Posts: 9
Joined: 16 May 2011 02:48

Re: Add Send to E-Mail Recipient to Tool Bar

Post by IMPVGO »

Thank-you very much for your answer. When applying this script on my button on the toolbar, my e-mail client opens with the attachment I have selected, but there is no subject or body....
Also, if I select several "tif" or "pdf" files to attach to the e-mail, I get the following message:

"An error occurred while creating a message compose window. Please try again"

When I use the "send to" option in the context menu works perfect, but I will like to place that option of e-mailing in the tool-bar.

Thanks in advance for any help in this regard

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Add Send to E-Mail Recipient to Tool Bar

Post by Stefan »

That's mostly about quoting.

Lets test:


Select a few file with blanks in file name or path

and use this two scripts in XYplorer address bar:
::text chr(39).get("SelectedItemsPathNames",",").chr(39);
'E:\temp\22 Accept - Restless and wild.mp3,E:\temp\Black Feat. Sabbath - Paranoid.mp3'

::text get("SelectedItemsNames",", ");
22 Accept - Restless and wild.mp3, Black Feat. Sabbath - Paranoid.mp3

Take an look at the output,
then try this:

::text chr(34).get("SelectedItemsPathNames",""", """).chr(34);
"E:\temp\22 Accept - Restless and wild.mp3", "E:\temp\Black Feat. Sabbath - Paranoid.mp3"


::text '"' . get("SelectedItemsNames",""", """) . '"'; // that '"' is ' + " + ' , the same as chr(34)
"22 Accept - Restless and wild.mp3", "Black Feat. Sabbath - Paranoid.mp3"

or
::text '"' . get("SelectedItemsNames","""<crlf>""") . '"';
"22 Accept - Restless and wild.mp3"
"Black Feat. Sabbath - Paranoid.mp3"


or just
::text get("SelectedItemsNames","<crlf>");
22 Accept - Restless and wild.mp3
Black Feat. Sabbath - Paranoid.mp3


I guess you see already what happens?

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Add Send to E-Mail Recipient to Tool Bar

Post by serendipity »

IMPVGO wrote:Thank-you very much for your answer. When applying this script on my button on the toolbar, my e-mail client opens with the attachment I have selected, but there is no subject or body....
Also, if I select several "tif" or "pdf" files to attach to the e-mail, I get the following message:

"An error occurred while creating a message compose window. Please try again"

When I use the "send to" option in the context menu works perfect, but I will like to place that option of e-mailing in the tool-bar.

Thanks in advance for any help in this regard
Stefan is right! i forgot to quote the subject and body. so here is a version which works for me:

Code: Select all

//Attach to Thunderbird
    $items=chr(39).get("SelectedItemsPathNames",",").chr(39);
    $itemnames=chr(39).get("SelectedItemsNames",", ").chr(39);
    run """C:\Program Files\Mozilla Thunderbird\Thunderbird.exe"" -compose subject=$itemnames,body=$itemnames,attachment=$items";

IMPVGO
Posts: 9
Joined: 16 May 2011 02:48

Re: Add Send to E-Mail Recipient to Tool Bar

Post by IMPVGO »

Works perfect serendipity, however, when I try to attach a file that is bigger than approximately 600 kb, it fails to attach. The e-mail client is opened, but the file is not attached, and nothing appears in the subject line or the body of the e-mail. Same thing when I try to attach for example 3 files that are larger than 100 kb. As I said before, this works okay when the attachment is made from the context menu. I have no idea why this happens. In any case, thank-you very much.

impvgo

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Add Send to E-Mail Recipient to Tool Bar

Post by serendipity »

IMPVGO wrote:Works perfect serendipity, however, when I try to attach a file that is bigger than approximately 600 kb, it fails to attach. The e-mail client is opened, but the file is not attached, and nothing appears in the subject line or the body of the e-mail. Same thing when I try to attach for example 3 files that are larger than 100 kb. As I said before, this works okay when the attachment is made from the context menu. I have no idea why this happens. In any case, thank-you very much.

impvgo
The problem is not the size, i think its the length of string that can be passed to the command line.
Eg: You can attach more items if the path is "D:\new.txt" compared to "C:\Documents and Settings\username\Desktop\new.txt"

Just tried to copy un-attachable files from desktop to D:\ and it attaches fine in shorter path.
Not sure what the limit is. Will find around and see what else works.

Anyway, use the below script which is easier to understand in case you want to learn scripting.

Code: Select all

//Attach to Thunderbird
//Get item's path and names
    $items=chr(39).get("SelectedItemsPathNames",",").chr(39);
//Get item's names
    $itemnames=chr(39).get("SelectedItemsNames",", ").chr(39);
//Insert values into Thunderbird syntax
    $TB_Syntax= chr(34)."subject=$itemnames,body=$itemnames,attachment=$items".chr(34);

//Attach selected files to thunderbird's compose window
    run """C:\Program Files\Mozilla Thunderbird\Thunderbird.exe"" -compose $TB_Syntax";

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Add Send to E-Mail Recipient to Tool Bar

Post by serendipity »

OK, here is another way using command prompt which supports longer string length. Again not sure what that number is.

Code: Select all

//Attach to Thunderbird
//Get item's path and names
    $items=chr(39).get("SelectedItemsPathNames",",").chr(39);
//Get item's names
    $itemnames=chr(39).get("SelectedItemsNames",", ").chr(39);
//Insert values into Thunderbird syntax
    $TB_Syntax= chr(34)."subject=$itemnames,body=$itemnames,attachment=$items".chr(34);

//Attach selected files to thunderbird's compose window 
//This method uses command prompt. 
    run "cmd /c cd /d C:\Program Files\Mozilla Thunderbird\ & thunderbird -compose $TB_Syntax";

admin
Site Admin
Posts: 65246
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Add Send to E-Mail Recipient to Tool Bar

Post by admin »

AFAIK Windows command lines must not exceed 2047 characters (XP).

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Add Send to E-Mail Recipient to Tool Bar

Post by serendipity »

admin wrote:AFAIK Windows command lines must not exceed 2047 characters (XP).
Thanks Don! Can confirm it. I checked the length of the string i am passing and above 2047 gave an error. But 2047 is for command prompt. For Run or openwith command its much lower, like close to 800. Any idea why?

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Add Send to E-Mail Recipient to Tool Bar

Post by Stefan »

serendipity wrote:Stefan is right! i forgot to quote the subject and body.
And also you doesn't quote the single items themself, doesn't that matter in this case?


serendipity wrote:The problem is not the size, i think its the length of string that can be passed to the command line.
Eg: You can attach more items if the path is "D:\new.txt" compared to "C:\Documents and Settings\username\Desktop\new.txt"
Hint for others reading this later:

one can use DOS command line command "subst" like
subst X: "C:\Documents and Settings\username\Desktop\"

to access files at "C:\Documents and Settings\username\Desktop\" via temporary drive "X:\"

and so save ~40 chars from command line length for each file.


--

Code: Select all

Test, nothing substed:
C:\Temp>subst



Read the help:
C:\Temp>subst /?
    Weist einem Pfad eine Laufwerkbezeichnung zu.
    SUBST [Laufwerk1: [Laufwerk2:]Pfad]
    SUBST Laufwerk1: /D


In XYplorer subst C:\Temp to A::
::run "cmd /c subst A: <curpath>";


The result:
C:\Temp>subst
    A:\: => C:\Temp


Test
Dir A:
is now the same as:
C:\Temp>Dir


Remove the subst and free A:
C:\Temp>subst a: /d


Test, nothing substed:
C:\Temp>subst


C:\Temp>

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Add Send to E-Mail Recipient to Tool Bar

Post by serendipity »

Stefan wrote:
serendipity wrote:Stefan is right! i forgot to quote the subject and body.
And also you doesn't quote the single items themself, doesn't that matter in this case?
Doesn't seem like, the example in the thunderbird doesn't mention it, plus the syntax is working for me:
http://kb.mozillazine.org/Command_line_ ... underbird)

the only problem seems the string length.

@Don: this page says, 8191 characters for XP and above. But I am getting errors already at 2047. Any idea why?
http://support.microsoft.com/kb/830473

admin
Site Admin
Posts: 65246
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Add Send to E-Mail Recipient to Tool Bar

Post by admin »

serendipity wrote:@Don: this page says, 8191 characters for XP and above. But I am getting errors already at 2047. Any idea why?
http://support.microsoft.com/kb/830473
No. The docs are wrong. :mrgreen:

Post Reply