Page 1 of 1

Drag and autorename post from Postbox

Posted: 24 Apr 2014 15:20
by ezne
Hello!

I am just beginning to play around with this amazing XYplorer. Is there any simple way to drag a message from Postbox email client into XYplorer and autorename the item in a similar fashion as it already does with Outlook?

Thank you in advance for any help

Re: Drag and autorename post from Postbox

Posted: 13 May 2014 09:26
by admin
I don't know Postbox. What happens when you try to do it?

Re: Drag and autorename post from Postbox

Posted: 28 May 2014 15:16
by ezne
Hello!

the email message gets copied in the target folder with eml extension and XY names the file with the subject of the email. Just that.

Re: Drag and autorename post from Postbox

Posted: 30 May 2014 13:54
by admin
Unlikely. I don't know Postbox and I cannot support every email client. Sorry.

Re: Drag and autorename post from Postbox

Posted: 30 May 2014 15:59
by bdeshi
I just downloaded and set up Postbox just to test this, and the funny thing is... if I drag an email from Postbox to XYplorer, "the email message gets copied in the target folder with eml extension and XY names the file with the subject of the email." So ezne, what's happening over there in your pc? What exactly do you want to happen?

Re: Drag and autorename post from Postbox

Posted: 30 May 2014 17:20
by Stef123
SammaySarkar wrote:I just downloaded and set up Postbox just to test this, and ... the email message gets copied in the target folder with eml extension and XY names the file with the subject of the email.
Yep. He got that part. But ...
ezne wrote: Just that.
What he expected to do (I guess) is ...
Help File wrote: When drag-dropping messages from Outlook or Outlook Express, this template controls the makeup of the new filenames. A template may, for example, look like this:
<from>_<to>_<subject>_<date yyyy-mm-dd_hh-nn-ss>
You can freely change the order of the fields and pack any text strings before, after or between ...

Re: Drag and autorename post from Postbox

Posted: 30 May 2014 18:45
by bdeshi
In that case, a custom button can be utilized (scripted with <get drop>) and the OP should get into the habit of dropping onto it.
I've AFK now, might try my hand at it (if no other scripter already gets to it... :whistle: )

Re: Drag and autorename post from Postbox

Posted: 30 May 2014 21:21
by ezne
Stef123> thank you for the clarification. It is exactly that what I am looking for

SammaySarkar> Yes, that would be a great solution. I am zero in scripting yet so if you manage to develop such a script it would be awesome

Re: Drag and autorename post from Postbox

Posted: 31 May 2014 13:10
by bdeshi
Here's a very basic script, it should (hopefully) rename the dropped file to <from>_<to>_<subject>.
Type ::snippet; into the addressbar and paste the following. A new user button with the openwith icon will be created. Drop emails onto that.

Code: Select all

Snip: CTB 1
  XYplorer 14.10.0107, 5/31/2014 10:14:02 PM
Action
  NewUserButton
Name
  EMLDrop
Icon
  :openwith
ScriptL
  $f = readfile(<get drop>);
   $from = regexreplace(regexmatches($f, '^From:(\s)?\".+\"'), 'From:(\s)?\"(.+)\"', $2);
   $to = regexreplace(regexmatches($f, '^To:(\s)?\".+\"'), 'To:(\s)?\"(.+)\"', $2);
   $sub = regexreplace(regexmatches($f, '^Subject:(\s)?.+'), 'Subject:(\s)?(.+)', $2);
   $tpl = replacelist(trim($from._.$to._.$sub, <crlf>), '|-/-\-?->-<-"-*-:','', '-');
   copyitem "<get drop>", "<curpath>\$tpl.eml";
   //delete 1, 0, "<get drop>";
ScriptR
  
FireClick
  0
[/size]
Theoretically it should make XY compatible with many other email client that allow .eml drops.

Re: Drag and autorename post from Postbox

Posted: 31 May 2014 21:39
by ezne
Hello SammaySarkar!

Thank you for your help with the script.

I created the drop button as you explained but unfortunately when dropping the message it does not recognise the From: and To: from the email.
It comes up with file with filename as __emailsubject.eml (two underscore signs followed by the email subject).

Please, check the script again and tell me if I need to correct anythin.

Re: Drag and autorename post from Postbox

Posted: 01 Jun 2014 05:35
by bdeshi
That's why I said it's basic, you see, there are a lot many possible fields and syntax variations in an eml file and I'd have to discover and account for all of them, which will take some time.
EDIT: Also you can try this one, see if it helps:

Code: Select all

Snip: CTB 1
  XYplorer 14.10.0109, 6/1/2014 9:48:56 AM
Action
  NewUserButton
Name
  EMLDrop
Icon
  :openwith
ScriptL
  $f = readfile(<get drop>);
   $from = regexreplace(regexmatches($f, '^From:(\s)?\".+\"'), 'From:(\s)?\"(.+)\"', $2);
   if $from == "" {$from = regexreplace(regexmatches($f, '^From:(\s)?.+'), 'From:(\s)?(.+)\s', $2);}
   $to = regexreplace(regexmatches($f, '^To:(\s)?\".+\"'), 'To:(\s)?\"(.+)\"', $2);
   if $to == "" {$to = regexreplace(regexmatches($f, '^To:(\s)?.+'), 'To:(\s)?(.+)\s', $2);}
   $sub = regexreplace(regexmatches($f, '^Subject:(\s)?.+'), 'Subject:(\s)?(.+)', $2);
   $tpl = replacelist(trim($from._.$to._.$sub, <crlf>), '|-/-\-?->-<-"-*-:','', '-');
   copyitem "<get drop>", "<curpath>\$tpl.eml";
  
ScriptR
  
FireClick
  0 
[/size]

I can see it having a lot more if/elseifs...

Re: Drag and autorename post from Postbox

Posted: 01 Jun 2014 15:57
by ezne
Thank you, the second script worked when substituting

Code: Select all

"<curpath>\$tpl.eml";


with

Code: Select all

"$tpl.eml";

Otherwise it created a folder with $from_$to_$sub as foldername, leaving the filename unchanged (just email subject).


The other challenge I found is that extracted To: and From: shows full name and email. Is there a simple way to finetune the script for limiting the result to just email addresses without the preceding full name?