Discussion Locked

Drag/drop msgs from Explorer to Outlook

0 helpful
25 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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?

25 replies

by carlos.nino

I'm not sure if tou are talking about messages saved on disk being dragged into Outlook, or messages from a web based application being dragged into Outlook.

by it_cowboy

I am talking about .msg format messages stored on a network drive or hard drive. There is nothing to do with web apps.

by it_cowboy

One URL referred to .NET (which the solution required is not) and the other I couldnt find anything to do with the question.

Thanks for trying.

by it_cowboy

Have already tried this.

This code returns messaages to the Drafts folder regardless of the Outlook folder selected and the message is unsent. When you open it, its ready to send. I need the messages back in Outlook in the format as if it had been sent (like drag/drop does).

Thanks anyway.

by kinetechs

Maybe this could offer another way to do it if the server is Exchange 200x.

Exchange 200x can use MS' INSTALLABLE FILE SYSTEM (what many call the M: drive). It maps the Exchange database to the local file system of the Exchange server. You can actually browse the M: drive (locally or network) and gain access to public and private folder that your account has permission to. The messages in Exchange folders will be in the .MSG format so it would probably be very easy to programatically move the messages from one file system to another (the M: drive). I've used to to do bulk exports of emails in the past.

Exchange 2000 will create the M: drive by default while Exchange 2003 won't, you'll have to configure it.

It may work for you.

Cheers!
~Sean

by it_cowboy

The solution I require needs to work without Exchange. I do understand what you are saying but its not what I am looking for.

Thanks anyway.

by it_cowboy

Thanks again, but already been here and this will not provide a suitable solution to the problem (see further comment at the top).

by it_cowboy

I think some more background here is required. I have been pursuing an answer to this for over 12 months.
- CDO is not an option
- Third party apps are not an option

.FileCopy(Filename,DestFolder) is not acceptable as you are limited to what folders to copy the message to and the date of the copied message is the date of when the copy was performed and not the original receive date of the message.

The closest I have got is opening the message with ShellExecute API, trapping the Explorer window and getting access to the MailItem. Then copy the MailItem object to the required Outlook folder. This option was not satisfactory as I could not work out a way to hide the opened Outlook Explorer window (ShellExecute will only hide .exe files).

The only way I can think to do it is emulating whatever Windows does when you manually drag & drop from Explorer to Outlook.

Hope this gives some context for future answers.

by digimesh

Still working on the exact code of this one but you can automate the import routine in outlook using VB. Is this the kinda thing you are after doing?

by tcallagh

What functions are being called when drag/drop is being activated. You may not beable to use VB/VBA without importing the libraries used to manage drag/drop within outlook. There is a routine there, you just need to watch what files are used, windows messages, registry reads, etc etc. I bet, in one of the outlook dll's, you will find the routine to accept drag/drop messages.

Sorry if not clear, it sounds good in my head.

Good luck!

by it_cowboy

Yep, understand what you are saying and makes sense. I think this is where I need to be, however I have not really been able to go too far here. I downloaded a dll watching program but it doesnt seem to tell me much. Once I find the dll that handles the function, where do I find the doco on the dll so I can program it to do what I want? This sort of thing is a little out of my league and would rely heavily on someone doing the ground work for me.

by fenaikh

Hi,
As you know outlook folders are special folders you can use Outlook Objects modles to access them.
There were 2 old articles in the accessadvisor magazine about these Objects modles.
MS site has what you want here
the full article is here and it has links.

Microsoft Outlook Objects

http://www.microsoft.com/OfficeDev/Articles/OPG/005/005.htm

Working with Outlook Folders
http://www.microsoft.com/OfficeDev/Articles/OPG/005/005.htm#PG005C2

Using Automation and VBScript
http://www.microsoft.com/OfficeDev/Articles/OPG/005/005.htm#PG005C4

more info :

Outlook Object Model

http://www.outlookexchange.com/articles/home/outlookobjectmodel.asp

good luck

Mohamed

by it_cowboy

Sorry, this is remedial and I was here many many months ago. I do this stuff in my sleep.

by tc1

Have you treid an Outlook add-in called Nelson Organizer. I think it can do this.

by it_cowboy

I dont need a 3rd party app to do this, windows already does it! You have missed the point. I offered 6000 points in an attempt to find a solution to a problem I have been bashing around for over 12 months. If I wanted a 3rd party app, I would have searched the internet.

Understand that I am the sort of person that pursues something under my own steam until I find an answer (and I usually do). I dont just post something because I cant be bothered. I have spend literally weeks of my time trying different avenues to achieve this result and have managed to do it several ways but these methods are unacceptable to me (they are not clean enough).

And I thought offering 6000 points would generate quality responses. Oh well.

by brian.clayton

Not looking for any points here, but try contacting Sue at slipstick.com. She is an authority on Outlook and should be able to point you in the right direction. What you are trying to do sounds like it should be simple, don't know why the powers that be make things so difficult...

by it_cowboy

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...

by johngreer

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 OutlookCode.com as well as vbCity, to no avail. I was hoping maybe you've figured this out while working on your solution.

by uweg

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 (http://www.dimastr.com/redemption/) and creating a postitem and import the msg-file to this postitem via a redemption-methode. Shoud also work as vb-program.

by gleedo

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 :)

by thierrynsaka

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

This discussion is closed to new replies.