General discussion


Drag/drop msgs from Explorer to Outlook

By IT_Cowboy ·
I know you can highlight multiple messages in Explorer then drag and drop them onto an Outlook folder to move the messages into Outlook.

I want to be able to do this programmatically (for multiple folders and messages). I have tried a multitude of avenues only to achieve unacceptable results.

I feel the only way to do this is to emulate the drag/drop action from Explorer to Outlook via code (VB/VBA please).

Does anyone have any ideas on how this might be done?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by IT_Cowboy In reply to

Yeah, I know who Sue is and have read many of her posts. She has helped me over the last couple of years. Its sounds agonisingly simple but all solutions I have come up with (3 or 4 different ways so far) are not 100% what I need. eg: The .FileCopy method on the Outlook Application object gets the .msg files into a folder in outlook, but not as a MailItem class and therefore do not list in Outlook as such. Spent many hours trying different things to get these file objects (they copy to outlook folders as olDocument class) to a MailItem class to no avail. However, if you double click to open the message, then click File > Copy to Folder, the result is a MailItem. But do you think I can find a way to do this programmatically? Its driving me mad... There must be a way.

Now, if you drag and drop a .msg file from explorer to Outlook, its goes into the folder as a MailItem object. Its that extra process that I need to find that checks out the file itself and converts it accordingly.

Thanks for the suggestion, I think that needs to be my next port of call...

Collapse -

by JohnGreer In reply to Drag/drop msgs from Explo ...

While researching this one, have you come across how to Drag an e-mail from Outlook onto a VB application? I can't seem to get this one, and I've asked in Sue's as well as vbCity, to no avail. I was hoping maybe you've figured this out while working on your solution.

Collapse -

by UweG In reply to Drag/drop msgs from Explo ...

I have nearly the same problem and worked out a outlook-macro which strip an attachment to harddisk and then import these *.msg-attachments back to the current outlook-folder. I only find a solution with use of the redemption.dll ( and creating a postitem and import the msg-file to this postitem via a redemption-methode. Shoud also work as vb-program.

Collapse -

by Gleedo In reply to Drag/drop msgs from Explo ...

Dim obj As Object
Dim objFolderEx As outlook.MAPIFolder ' some other folder'
Dim objInboxFolder As outlook.MAPIFolder
Dim sFile as string

sFile = "c:\mymsg.msg" ' path to your msg file(s)

' set objFolderEx to some other outlook folder
set objFolderEx = ...

' create an object of your msg file using CreateItemFromTemplate method
Set obj = OUTLOOKInstance.CreateItemFromTemplate(sFile, objFolderEx)

' get pointer to the outlook folder you want to import into
Set objInboxFolder = objNS.GetDefaultFolder(olFolderInbox)

On Error Resume Next
' move your object from folderex to import folder
obj.Move objInboxFolder

this solution should work ok. If your try and create the object directly into your required destination outlook folder first off, i could not get it to appear, so thats why i import it into another folder first.

I hope this helps :)

Collapse -

by thierrynsaka In reply to Drag/drop msgs from Explo ...

Hi all,
Gleedo deserves the 6000 points. Too bad for you IT_Cowboy, too bad it took 15 months to get a good answer.
Gleedo has it absolutely right. I've tested her/his solution and it does work.
Thanks to all for your discussion. I've been searching for an answer for 1 day!!!
Thanks Gleedo

Related Discussions

Related Forums