Drop files on CTB from Outlook

Discuss and share scripts and script files...
Post Reply
Caz
Posts: 35
Joined: 31 Oct 2018 09:12

Drop files on CTB from Outlook

Post by Caz »

Hi,
I am trying to create a CTB that would execute a script when files are dropped on it.
The files would come from Outlook email attachements.
Using "text <get drop>;" I get the list of the dropped files when selected from XYplorer or Windows Explorer.
But this is not working with Outlook email attachments. The list is empty.
Is there a workaround to make it work or should I think of another way to deal with my script ?
Thanks.
Caz.

highend
Posts: 13308
Joined: 06 Feb 2011 00:33

Re: Drop files on CTB from Outlook

Post by highend »

But drag'n drop of Outlook attachments into XYplorer (so that a copy is created in the current folder) works?
One of my scripts helped you out? Please donate via Paypal

Caz
Posts: 35
Joined: 31 Oct 2018 09:12

Re: Drop files on CTB from Outlook

Post by Caz »

Yes that works !

Caz
Posts: 35
Joined: 31 Oct 2018 09:12

Re: Drop files on CTB from Outlook

Post by Caz »

I used VBA as a workaround for now but I am interested if anybody as a method to make it work in a script.

highend
Posts: 13308
Joined: 06 Feb 2011 00:33

Re: Drop files on CTB from Outlook

Post by highend »

I used VBA as a workaround
By doing what?
One of my scripts helped you out? Please donate via Paypal

Caz
Posts: 35
Joined: 31 Oct 2018 09:12

Re: Drop files on CTB from Outlook

Post by Caz »

I need a script that creates files before attachments are dropped in XYplorer.
I wanted to use a CTB on which I could drop my attachments.
As a workaround I use VBA to get the attachment filenames and launch a script in XY to create the files I need.
Then I drag and drop the attachments.
So 2 operations when I think only one should be possible.

highend
Posts: 13308
Joined: 06 Feb 2011 00:33

Re: Drop files on CTB from Outlook

Post by highend »

Show the vbs script^^
One of my scripts helped you out? Please donate via Paypal

Caz
Posts: 35
Joined: 31 Oct 2018 09:12

Re: Drop files on CTB from Outlook

Post by Caz »

Probably not a clean and optimised code (I am no expert).

Code: Select all

Public Sub CopyAttachmentFilenames()
    Dim selItem As Object
    Dim aMail As mailItem
    Dim aAttach As attachment
    Dim Report As String
    Dim XYplorer As String
    Dim clipboard As MSForms.DataObject
    Set clipboard = New MSForms.DataObject   
    For Each selItem In Application.ActiveExplorer.Selection
        If selItem.Class = olMail Then
            Set aMail = selItem
            For Each aAttach In aMail.Attachments
                Report = Report & aAttach.FileName & vbCrLf
            Next
        End If
    Next
    clipboard.SetText Report
    clipboard.PutInClipboard
    XYplorer = "C:\Users\***\XYplorer\attachments.bat"
    Call Shell(XYplorer)
End Sub

highend
Posts: 13308
Joined: 06 Feb 2011 00:33

Re: Drop files on CTB from Outlook

Post by highend »

I'm confused...
As a workaround I use VBA to get the attachment filenames and launch a script in XY to create the files I need.
Then I drag and drop the attachments.
The vba file (you do execute it from within Outlook, correct?) gets all attachments (their file names) from the current mail,
puts them into a <crlf> separated list and stores that list in the clipboard. Afterwards a .bat file is called, which does
"<something>"... And afterwards you additionally drag and drop those files. Em, where and why? XY doesn't recognize that
drop on the CTB as you said.

Post the script on your button as well, please.

As long as XY doesn't recognize the drop on any other element than the file list itself the only workaround I see is to run
code from your button (like: connect to Outlook, get attachments, store them <somewhere>/do something with them) which gets the attachments from the current mail in Outlook. In other words: No drag and drop at all and "the other way round", XY "gets" mail attachments from Outlook.
One of my scripts helped you out? Please donate via Paypal

Caz
Posts: 35
Joined: 31 Oct 2018 09:12

Re: Drop files on CTB from Outlook

Post by Caz »

What I need to do is create empty files with the same filenames as the attachments before I drag and drop them.
I wanted to do a single script in XY and drop the files on the CTB so as to create the empty files prior to the drop effectively happens (in a single operation).
I couldn't manage to do that.

As a workaround I use a VBA code to create a list of the attachments filenames and put it in the clipboard.
Then launch a XY script (through a bat file) from VBA that creates the empty files.
Then I can drag and drop the attachments, not on the CTB but in the active tab as the empty files already exist.

Hope it is more clear now.

highend
Posts: 13308
Joined: 06 Feb 2011 00:33

Re: Drop files on CTB from Outlook

Post by highend »

I've asked this:
But drag'n drop of Outlook attachments into XYplorer (so that a copy is created in the current folder) works?
And you said that this works^^

But you didn't mention (at that place) that this only works if you've created empty files with the same names (base + extension) of the names
of the attachments before doing the drag and drop...

Why don't you call XY itself with a /script= command line instead of using an intermediate .bat file then?
E.g with the following one-liner.:

Code: Select all

/script="::foreach($item, <clp>, <crlf>, 'e') { writefile($item); }"
This takes <crlf> separated file names (with no! paths) from the clipboard and creates empty files
with these names in the current folder (in the active list pane)
One of my scripts helped you out? Please donate via Paypal

Caz
Posts: 35
Joined: 31 Oct 2018 09:12

Re: Drop files on CTB from Outlook

Post by Caz »

highend wrote: 23 Nov 2018 13:29 I've asked this:
But drag'n drop of Outlook attachments into XYplorer (so that a copy is created in the current folder) works?
And you said that this works^^
But you didn't mention (at that place) that this only works if you've created empty files with the same names (base + extension) of the names
of the attachments before doing the drag and drop...
No this works like in Windows Explorer. No need to create empty files with the same names.
For some reasons I want to create this empty files before drag and drop.
Why don't you call XY itself with a /script= command line instead of using an intermediate .bat file then?
E.g with the following one-liner.:

Code: Select all

/script="::foreach($item, <clp>, <crlf>, 'e') { writefile($item); }"
This takes <crlf> separated file names (with no! paths) from the clipboard and creates empty files
with these names in the current folder (in the active list pane)
Because I am still learning :wink:
I'll try your solution.
And your solution made me discover that I could copy the attachments in the clipboard. That opens new way of achieving my script !
Thanks.

Post Reply