Drag and Drop attachements from e-mail


Freddy Dewulf
 

Hi group,
We are using magic xpa 3.3d.
Suppliers send their invoice via e-mail.
Our customers want to select an attachement (pdf) and drop it in the application.
Next, the program has to open the pdf and show it in a subscreen.
With the drag and drop function, it's possible to select a file from the explorer and drop it in the application.
I'm wondering if there is a smart way to accomplish this, so selecting one or more attachements from an e-mail.

Here I found a working procedure (2008) to drag and drop an e-mail from outlook. The program gives an overview of the attachements and the user has to select the attachement(s) he wants.
Of course, it's possible to adapt this procedure, but the procedure starts from an e-mail, not from the attachements. This procedure uses COM objects for Outlook. I don't know if it works for other e-mail clients.

Tia
Freddy


Adrian Wick
 

Hello,

I also would like to know if it is possible to drag the attachment directly from the email and drop it into a form in magic.

Looking at the onlinesample everything is done from the physical file, But how to do this from other apps. And the 
blob itself is setup as image. What about pdfs ... 

Regards,
A


Harry Kleinsmit
 

Hi Adrain,

Yes, it is possible with a C# snippet, but you will probably need a different approach for it.

You will need a couple of .NET variables:
   N_Dropzone :System.Windows.Forms.TextBox (put this one on your form)
   N_MemoryStram: System.IO.MemoryStream
   N_FileStream: System.IO.FileStream
   N_DragEvents: System.Windows.Forms.DragEventArgs
   N_FileInfo: System.IO.FileInfo

and then the event to capture either a file from Outlook of from Disc would be something like this:



where the C# snippet is:


Argument = NT (=e)

and the following expressions are:
37: DNCast(NT.Data.GetData('FileContents'),DotNet.System.IO.MemoryStream)  {where NT= e}
44: StrToken(NN,StrTokenCnt(NN,'\'),'\')   {Strip the path}
45: Trim(HJ)&Trim(NN)    (Path & TargetFileName)
48: DotNet.System.IO.FileStream(NN,DotNet.System.IO.FileMode.CreateNew)  {Write the stream to disc}

39: DotNet.System.String.Join(',',NT.Data.GetData('FileName','TRUE'LOG))  {where NT=e}

Hope this helps.

Best regards,
Harry Kleinsmit.


On Fri, Feb 3, 2023 at 08:36 AM, Adrian Wick wrote:
Hello,

I also would like to know if it is possible to drag the attachment directly from the email and drop it into a form in magic.

Looking at the onlinesample everything is done from the physical file, But how to do this from other apps. And the 
blob itself is setup as image. What about pdfs ... 

Regards,
A


Adrian Wick
 
Edited

Thank you Harry!!!

Can you post the other variables also? Like what are MV, NO and NN variables? And expcalc('42'exp) the 1st variable?

Thank you for your help!

Regards,
A

p.s. so far dragging the existing files on the computer works, I get the "filepath" of the dragged object. I tried to dragged it
from Notes mail and the event didn't even recognize the drop ...


Harry Kleinsmit
 

Hi Adrian,

These variables are (translated):

MV= StringWithFilenames (Unicode, 5000)
NO = ExtensionOutlookDrop (Alpha, 10)
NN = FullPathnameTarget (Alpha, 240)
ExpCalc('42'EXP) = StrTokenIdx(H_AllowedExtensions,Trim(H_ExtensionOutlookDrop),',')>0

Best regards,
Harry Kleinsmit.


On Sat, Feb 4, 2023 at 09:45 PM, Adrian Wick wrote:
Thank you Harry!!!

Can you post the other variables also? Like what are MV, NO and NN variables? And expcalc('42'exp) the 1st variable?

Thank you for your help!

Regards,
A

p.s. so far dragging the existing files on the computer works, I get the "filepath" of the dragged object. I tried to dragged it
from Notes mail and the event didn't even recognize the drop ...


Adrian Wick
 

On Sun, Feb 5, 2023 at 04:54 AM, Harry Kleinsmit wrote:
H_AllowedExtensions
What about this one?

And the raise event you have is for doing something with the file itself I guess?

I think I got everything else figured out. Thank you! 


Harry Kleinsmit
 

Hi Adrian,

The H_AllowExtension = "pdf,jpg,jpeg,tif,tiff,png,doc,docx,xls,xlsx,bmp" or change whatever you want to accept in your program.

The RaiseEvent "VerplaatsGedropteBestanden" moves the dropped files as follows:



Expressions:
31: 
32: 

So you can drop several files at once too. But this is not implemented for dropping files from Outlook! If you figure out how to do that then please let me know!

Best regards,
Harry Kleinsmit.


On Sun, Feb 5, 2023 at 05:38 AM, Adrian Wick wrote:
On Sun, Feb 5, 2023 at 04:54 AM, Harry Kleinsmit wrote:
H_AllowedExtensions
What about this one?

And the raise event you have is for doing something with the file itself I guess?

I think I got everything else figured out. Thank you! 


Adrian Wick
 

Thank you!

Will report back if I figure something out!

Thank you!