Results 1 to 20 of 20

Thread: [2005] File/Email DragDrop

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member ProphetBeal's Avatar
    Join Date
    Aug 2006
    Location
    New York
    Posts
    424

    [2005] File/Email DragDrop

    I searched high and low for a way in VB.NET to be able to drag and drop Outlook emails onto a control or form. The closest thing I could find was written in C# and posted by FabioPoroli.

    What I did is convert the code to VB.NET and modify it to work with any control or a form. (The original code created a custom control to capture the dropped items.)

    The only known issue is when you drop multiple files from the file system it will only grab the first file. (I'm still trying to resolve this problem any help would be greatly appreciated.)

    The code is attached in the Zip file and below is how to implement the code.

    VB.NET Code:
    1. Public Class Form1
    2.     Private WithEvents clsDropProcess As DragDropProcess.DragDropProcess  'This is so we can handle the drop event
    3.  
    4.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.         Me.ListBox1.AllowDrop = True 'You have to set AllowDrop on the control you wish to use to [i]True[/i]
    6.         clsDropProcess = New DragDropProcess.DragDropProcess(ListBox1) 'Create a new instance of the class and pass the control that you want to allow files to be dropped on
    7.         AddHandler clsDropProcess.DroppedByteArrayAvailable, AddressOf DropEvent 'Add a handler to get the files/emails that have been dropped
    8.     End Sub
    9.  
    10.     Public Sub DropEvent(ByVal sender As Object, ByVal filename As String, ByVal bytes As Byte()) 'This is the event that will fire for each file/email that is dropped.
    11.         'Add code to do whatever you want with the file.
    12.     End Sub
    13. End Class

    I hope everyone finds this as useful as I have.
    Attached Files Attached Files

    Helpful Links:
    VB 6 - How to get the "Key" Value in a collection
    VB.NET - File Search Utility || VB.NET - How to compare 2 directories || VB.NET - How to trust a network share
    VB.NET - Create Excel Spreadsheet From Array || VB.NET - Example Code & Hints you may not know
    VB.NET - Save JPEG with a certain quality (image compression) || VB.NET - DragDrop Files, Emails, and Email Attachments

    Please post some of the code you need help with (it makes it easier to help you)
    If your problem has been solved then please mark the thread [RESOLVED].
    Don't forget to Rate this post

    "Pinky, you give a whole new meaning to the phrase, 'counter-intelligence'."-The Brain-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width