?
Solved

Drag N Drop outlook contacts into a vb6 application

Posted on 2011-05-03
5
Medium Priority
?
776 Views
Last Modified: 2012-05-11
Hi There

I need to be able to drag and drop a contact from Outlook into a VB6 application.
I'm comfortable with the receiving part in VB6 e.g. (Data As DataObject)
but how can I extract the contact information from this object?

I've searched and searched for this but can't find any solution.

All help greatly receivied.
0
Comment
Question by:SamSherwin
  • 3
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
lludden earned 2000 total points
ID: 35516535
Here is the code for VB.net.  It should be similar under VB6

    Private Sub TextBox2_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragDrop
        If e.Data.GetDataPresent("RenPrivateItem") Then
            Dim OL As Microsoft.Office.Interop.Outlook.Application = CType(GetObject(, "Outlook.Application"), Microsoft.Office.Interop.Outlook.Application)
            Dim mi As Microsoft.Office.Interop.Outlook.ContactItem
            For Each mi In OL.ActiveExplorer.Selection()
                TextBox2.Text &= mi.Email1DisplayName
            Next
        End If
    End Sub

    Private Sub TextBox2_DragEnter(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles TextBox2.DragEnter
        If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
            e.Effect = DragDropEffects.Copy
        ElseIf e.Data.GetDataPresent("RenPrivateItem") Then 'Outlook message
            e.Effect = DragDropEffects.Copy
        ElseIf e.Data.GetDataPresent("FileGroupDescriptor") Then 'or this tells us if it is an Outlook attachment drop
            e.Effect = DragDropEffects.Copy
        Else 'or none of the above
            e.Effect = DragDropEffects.None
        End If
    End Sub
0
 

Author Comment

by:SamSherwin
ID: 35516647
Thanks for your effort but there is lots of vb.net example code around, vb6 does not have the luxury of the .net framework.

If you're able to convert this to VB6 that would be fantastic.

Thanks

sam
0
 
LVL 18

Expert Comment

by:lludden
ID: 35516887
This isn't using any framwork.  It is all COM objects.  
0
 

Author Comment

by:SamSherwin
ID: 35688720
OK, thanks for that, unfortunately as this uses COM outlook pops up a warning that its being accessed, although it works its not a practical solution.

I've come across emorcillo who provided a fantastic solution for a similar problem but for emails froms Outlook.

He also did have a solution for dropping contacts from Outlook but for some reason this is the only link on his, no longer supported, web site that does not work.

http://www.mvps.org/emorcillo/en/code/vb6/index.shtml "Getting fields from dropped Outlook contacts"  --> outlookcontacts.zip


Anyone got this file or anyone know how to do this without com?

Thanks

Sam
0
 
LVL 18

Expert Comment

by:lludden
ID: 35689954
If the security warning is a problem, you will need to use Outlook Redemption (http://www.dimastr.com/redemption/) or something similar.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

I came across an unsolved Outlook issue and here is my solution.
As a matter of fact, Outlook OST files are of much importance in relation to Exchange mailbox. OST files are independent as they are simply copy of data of a user’s mailbox on Exchange Server. Though, if the server’s status is changed or it is dama…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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