Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Dragging an e-mail from Outlook 98 into a Listbox

Posted on 2003-03-25
8
Medium Priority
?
265 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

569 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