Drag and autorename post from Postbox

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
ezne
Posts: 13
Joined: 24 Apr 2014 15:09

Drag and autorename post from Postbox

Post 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

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

Re: Drag and autorename post from Postbox

Post by admin »

I don't know Postbox. What happens when you try to do it?

ezne
Posts: 13
Joined: 24 Apr 2014 15:09

Re: Drag and autorename post from Postbox

Post 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.

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

Re: Drag and autorename post from Postbox

Post by admin »

Unlikely. I don't know Postbox and I cannot support every email client. Sorry.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Drag and autorename post from Postbox

Post 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?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Stef123

Re: Drag and autorename post from Postbox

Post 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 ...

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Drag and autorename post from Postbox

Post 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: )
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

ezne
Posts: 13
Joined: 24 Apr 2014 15:09

Re: Drag and autorename post from Postbox

Post 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

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Drag and autorename post from Postbox

Post 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.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

ezne
Posts: 13
Joined: 24 Apr 2014 15:09

Re: Drag and autorename post from Postbox

Post 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.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Drag and autorename post from Postbox

Post 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...
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

ezne
Posts: 13
Joined: 24 Apr 2014 15:09

Re: Drag and autorename post from Postbox

Post 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?

Post Reply