?
Solved

Dragging an e-mail from Outlook 98 into a Listbox

Posted on 2003-03-25
8
Medium Priority
?
264 Views
Last Modified: 2008-02-01
Does anyone have any idea of how to drag an e-mail from Outlook 98, the e-mail has an msg extension, and drop the file into a Listbox?  I mean copy the whole file into a listbox, not just read the text into it.  I've been racking my brain trying to use the OLEDragDrop method of the listbox and it's driving me nuts!!
0
Comment
Question by:kaiserr2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 1

Expert Comment

by:advapp
ID: 8206689
I'm not sure I understand: You want the "whole file into a listbox"?  But a listbox, by definition will display only a single line of text per record/row/item.
0
 

Author Comment

by:kaiserr2
ID: 8206788
Im open to suggestions, doesn't have to be a listbox.  My main concern is being able to just drop the .msg into something and have the ability to double click it and open the e-mail.  The latter I can handle but it's the actual copying of the file into *some sort of control*, not necessarily a listbox, that's killing me.
0
 
LVL 1

Expert Comment

by:advapp
ID: 8206911
So, is it the DragNDrop mechanism you cannot get working?  Or is it that you get notification of the drop but cannot figure out how to get access to the message object?  Just trying to narrow the scope a little.

I have experience with Outlook and with DragNDrop so I expect I can help you here.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:kaiserr2
ID: 8210075
The code of the OLEDragDrop event on the object I wish to drop the e-mail is the specific problem.  And for the record I have no idea how to access the message object.  Basically I've never tried programming with Outlook before and this whole thing has thrown me for a loop.
0
 
LVL 1

Accepted Solution

by:
advapp earned 480 total points
ID: 8212136
Here is what I have done in the past to implement DragNDrop:

Set your target control properties as:
     OLEDropMode = [1 - ccOLEDropManual]

In the form (NOTE: my control is lstPrograms):

Private Sub lstPrograms_OLEDragDrop(data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, Y As Single)

    If Effect And vbDropEffectCopy Then
        Effect = vbDropEffectCopy
    End If

    If data Is Nothing Then
        'No data was passed??
    ElseIf data.GetFormat(vbCFText) Then
     GetItemText data
    ElseIf data.GetFormat(vbCFFiles) then
        AddPrograms data
    End If

    DragOverList = False

End Sub

Private Sub lstPrograms_OLEDragOver(data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, Y As Single, State As Integer)
   
    If Not DragOverList Then
        DragOverList = True
        If data.GetFormat(vbCFFiles) _
          Or data.GetFormat(vbCFText) Then
            Effect = Effect And vbDropEffectCopy
        Else
            Effect = vbDropEffectNone
        End If
    End If

End Sub

Private Sub AddPrograms(data As Object)
'Given a DataObject, iterate the collection of files,
'and add the program names to the list
Dim i As Integer

    For i = 1 To data.Files.Count
     'Get the file name and validate
        'data.Files(i) is a string containing the full pathname of each program
        'Additional massaging of the name can be done using the FSO methods
        lstPrograms.AddItem data.Files(i)
    Next

End Sub

Private Sub GetItemText(data As Object)
'Get the text

    lstPrograms.AddItem data.GetText(vbCFText)

End Sub
0
 
LVL 1

Expert Comment

by:advapp
ID: 8212167
Oops.  That entry in GetItemText should read:

lstPrograms.AddItem data.GetData(vbCFText)


What Outlook gives you in the data object is something like this:

From    Subject Received    
Bob Terzian FW: OS Request for new hire associate, Request#3438 Tue 3/25/2003 2:19 PM  

Of course, from this info, you would have to then be able to go into the Outlook object model and retrieve the actual message object.
0
 

Author Comment

by:kaiserr2
ID: 8212212
Wow dude, even if this doesn't work Im going to give you the points anyways.  Thanks for the help, all I needed was a little sample code to work from.
0
 
LVL 1

Expert Comment

by:advapp
ID: 8212234
Thanks.  If you need additional help figuring out the Outlook object stuff I can assist with that.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question