1

When I drag a file attachment from Outlook Online (Web, rendered in Firefox) to my app, I receive the following drop elements:

Dropped elements

But how do I get the attachment contents (the raw bytes of the attachment) from these? None of the elements are big enough to contain the 250K file that is attached, and the IStream content consists just of these 16 bytes:

00 00 00 00  01 00 00 00  00 00 00 00  00 00 00 00

My suspicion is that it is this IStream that I must use to stream the bytes from the browser to my application, but I can't fathom how to convert these bytes to a stream in my Delphi application.

Edit: JSON from application/x-moz-custom-clipdata:

{
   "itemType":"attachment",
   "attachmentFile":{
      "attachmentItemId":"AAM...BASE64...H6M=",
      "name":"<FileName>.pdf",
      "size":254330,
      "fileType":5,
      "type":"ItemIdAttachment:#Exchange",
      "ContentType":"application/pdf"
   }
}
AmigoJack
  • 5,234
  • 1
  • 15
  • 31
HeartWare
  • 7,464
  • 2
  • 26
  • 30
  • As per [CodeProject: Windows Clipboard Formats](https://www.codeproject.com/Reference/1091137/Windows-Clipboard-Formats): "_Used internally by the Windows drag/drop helpers_" and as such surely lacking any documentation. Also linking [The Drag and Drop Component Suite for Delphi](http://melander.dk/delphi/dragdrop) as for the screenshot used. – AmigoJack May 17 '22 at 09:34
  • Have you tried looking at the content of `application/x-moz-custom-clipdata`? It should contain structured data - in json format I think - that should tell you more... – Rob Lambden May 17 '22 at 10:08
  • @RobLambden: Yes, I have looked at it, and have extracted the file name from there, but the other JSON data is not something that I can interpret. I'll update the question with the data... – HeartWare May 17 '22 at 10:10
  • 1
    So you can see from the available data that this is information about the attachment. At this stage it has not been downloaded so the browser doesn't have it, it just knows that the server has it. If you download it in the browser then it will be available as any downloaded file. If you want to download it yourself then you will need to interact with the Exchange server to get the attachments for the message, but it looks as though the `attachmentItemId` is not complete. You don't have enough information to identify the message and/or attachment. – Rob Lambden May 17 '22 at 10:42
  • @RobLambden: If you're referring to the "...BASE64..." part of the attachmentItemId, it's my edit to shorten it (I don't expect the exact value of this field is important to the answer to the question, although it might be important for the implementation of the solution, once the solution has been determined. – HeartWare May 17 '22 at 10:47
  • @RobLambden: Anyway, I can see that I can't even drag'n'drop it to the desktop, so perhaps it is not possible to do this... – HeartWare May 17 '22 at 10:51
  • 1
    As per my previous comment, the browser does not have the attachment, so you can't drag it from the browser to anywhere. However it does know there is an attachment. It can give you that information, and that then allows your program to download it yourself, but that will require you to talk to the Exchange Server. If it's viable then your quickest (and probably most reliable) solution is going to be to train the users to download the attachment and then drag the downloaded file to your program. – Rob Lambden May 17 '22 at 10:54
  • @RobLambden: That's also my conclusion. I had hoped that the browser (actually, the web page) could handle this (as it can download it, it would be possible - technically - to make an IStream interface available that'll download it from the Exchange server and stream it to me). However, this has not been done (understandably, but one can hope :-)), so it seems like the workaround (that we currently tell our users) is the only way to go. – HeartWare May 17 '22 at 10:58

2 Answers2

0

Use TOleStream from Vcl.AxCtrls to convert from IStream to TStream and read the bytes.

dwrbudr
  • 607
  • 4
  • 8
0

you must user Graph API to get attachemen file

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 17 '22 at 06:35