# Drop email to ListBox

**URL:** <https://forum.xojo.com/t/drop-email-to-listbox/19128>\
**Category:** macOS\
**Created:** [September 7, 2014, 7:16am UTC](https://forum.xojo.com/t/drop-email-to-listbox/19128 "2014-09-07T07:16:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Horst\_Jehle](https://forum.xojo.com/user_avatar/forum.xojo.com/horst_jehle/32/5432_2.png) [@Horst\_Jehle](https://forum.xojo.com/u/Horst_Jehle)\
**Post date:** [September 7, 2014, 7:16am UTC](https://forum.xojo.com/t/drop-email-to-listbox/19128/1 "2014-09-07T07:16:51Z")

</div>

Does anyone know, how can I drag and drop an email from apple mail directly into a Listbox? When I drag an email to a folder location, OS X makes a .elm file on the dropped folder location. I would have the same function with a listbox. Drop an email from apple mail to a listbox and the dojo application copy this email as an .elm file to another folder location.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [September 7, 2014, 8:15am UTC](https://forum.xojo.com/t/drop-email-to-listbox/19128/2 "2014-09-07T08:15:52Z")

</div>

have you read [DragItem](http://documentation.xojo.com/index.php/DragItem), [ListBox](http://documentation.xojo.com/index.php/ListBox) (DropObject Event) ?

Now, I am not sure that a ListBox is the answer to your question.

Do you want to get the text of the mail in a ListBox Cell ???

I do not. Maybe a TextArea will be better (some mails have styled text).

Note: I never tried to do what your question tell and worst, I never used Mail.  
I hope these good sense answer will help.

---

<div class="post-metadata">

**Author:** ![Horst\_Jehle](https://forum.xojo.com/user_avatar/forum.xojo.com/horst_jehle/32/5432_2.png) [@Horst\_Jehle](https://forum.xojo.com/u/Horst_Jehle)\
**Post date:** [September 7, 2014, 8:22am UTC](https://forum.xojo.com/t/drop-email-to-listbox/19128/3 "2014-09-07T08:22:17Z")

</div>

The Listbox cell should have the email subject like \<[New Reply] Drop email to ListBox.elm\> and the complete email should be saved or copied to a folder. The same function, when you drop an email from apple mail to any folder. You get a new file called \<[New Reply] Drop email to ListBox.eml\>.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [September 7, 2014, 10:16am UTC](https://forum.xojo.com/t/drop-email-to-listbox/19128/4 "2014-09-07T10:16:36Z")

</div>

OK, so you will have a one column ListBox with the eMail Subject line of your mails as the Cell contents and export to disk the mail contents ?

So, you have to add the ListBox [DropObject](http://documentation.xojo.com/index.php/RectControl.DropObject) Event.  
Then, in `Obj As DragItem`:

Add a string variable (to hold the mail contents: Obj.Text),  
Add a FolderItem variable (to store the mail into file),  
Search the contents of the Subject field,

Add a Row and place the subject field into it,

Create a Text File, use the subject field as the file name,  
Store into that file the mail contents.

At that moment, you can store the Mail FolderItem in the CellTag for later use (in that session).

In later sessions, open the folder where you store the mails, and insert in the ListBox the name of the files found there (and do not foret to store in CellTag the FolderItem for each Mail text file.

I think I forgot something Ah ! the read the mail part !  
A click / selection in a Row loads the mail text and store its contents in a TextArea, using the FolderItem found in the CellTag.

Need more: Just ask.

---

<div class="post-metadata">

**Author:** ![Horst\_Jehle](https://forum.xojo.com/user_avatar/forum.xojo.com/horst_jehle/32/5432_2.png) [@Horst\_Jehle](https://forum.xojo.com/u/Horst_Jehle)\
**Post date:** [September 7, 2014, 12:04pm UTC](https://forum.xojo.com/t/drop-email-to-listbox/19128/5 "2014-09-07T12:04:01Z")

</div>

Sorry, Listbox does not accept dropping an email. I have this in the open event  
me.AcceptFileDrop(FileTypesAttachments.All)  
me.AcceptRawDataDrop("???")  
me.AcceptMacDataDrop “public.message”  
me.AcceptFileDrop(FileTypesAttachments.ApplicationEML)  
me.AcceptMacDataDrop “public.plain-text”  
me.AcceptMacDataDrop “public.mime-type”  
me.AcceptTextDrop

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [September 7, 2014, 12:16pm UTC](https://forum.xojo.com/t/drop-email-to-listbox/19128/6 "2014-09-07T12:16:34Z")

</div>

Sorry Horst, I do not know how to get the drop contents / kind.

You certainly know, but instructions with File in them are useless here (me.AcceptFileDrop for example).  
(I understand: you tried anything that comes to mind)

I have a stupid idea (better than nothing):

select in Mail what you want to drag,  
copy it in the Clipboard,  
run Script Editor  
copy / paste: `return clipboard info`

you will get something like:

```auto
{{«class utf8», 198}, {«class ut16», 398}, {string, 198}, {Unicode text, 396}}
```

(that was text copied from FireFox - remember I do not use mail, never run it).

In Safari, I selected a web page with styled text and images and that gives:

`{{«class weba», 116421}, {«class rtfd», 95914}, {«class RTF », 11190}, {«class utf8», 1683}, {«class ut16», 3310}, {uniform styles, 18572}, {string, 1654}, {scrap styles, 2042}, {Unicode text, 3360}, {uniform styles, 18572}, {scrap styles, 2042}}
`  
I hope this will goives you ideas to continue

I have to leave internet now and be back tomorrow morning only.

---

<div class="post-metadata">

**Author:** ![Axel\_Schneider](https://forum.xojo.com/user_avatar/forum.xojo.com/axel_schneider/32/465_2.png) [@Axel\_Schneider](https://forum.xojo.com/u/Axel_Schneider)\
**Post date:** [September 7, 2014, 1:13pm UTC](https://forum.xojo.com/t/drop-email-to-listbox/19128/7 "2014-09-07T13:13:05Z")

</div>

I’ve done some tests  
In Mail I have a email with the subject “testmail”

if I drag the email to the Finder I get a eml file (testmail.eml)

if I drag the email to TextEdit or to a Xojo TextArea I get a Link.  
message:%3C1BCF2A04-ADC9-45CC-BA7D-80A9AD8929A3@googlemail.com%3E

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:24pm UTC](https://forum.xojo.com/t/drop-email-to-listbox/19128/8 "2020-10-29T17:24:30Z")

</div>


