Drag and drop Outlook email into Excel Userform to capture email details and attachments

bradyboyy88

Well-known Member
Joined
Feb 25, 2015
Messages
562
Basically I am trying to see if this is even possible. Taking an email and dragging it over some userform object such that when the user lets go it captures information from the email such as a unique ID of some sort and the attachments ( I am going to extract these and save in another directory). Starting my research now but curious if anyone knows any shortcuts to making this happen?
 
That's not what you said earlier - you said an Excel ribbon item.

You should be able to use GetObject to get the Outlook application, then use its Commandbars collection to add a new button to the AddIns tab (I have not tested so this may be wrong - Outlook can be weird!) but how you would get that to call code in your Excel workbook might be trickier. It may be simpler to use events to monitor Outlook temporarily - I'll have a think.

Can outlook events be captured from excel application? Or if the button can be added from commandbars then couldnt I dynamically add a macro to outlook on the fly as well? I have seen a few posts of people creating real time macros with vbe . Might be messy.
 
Last edited:
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
That's not what you said earlier - you said an Excel ribbon item.

You should be able to use GetObject to get the Outlook application, then use its Commandbars collection to add a new button to the AddIns tab (I have not tested so this may be wrong - Outlook can be weird!) but how you would get that to call code in your Excel workbook might be trickier. It may be simpler to use events to monitor Outlook temporarily - I'll have a think.

So for the [FONT=&quot]MSComctlLib object. If you take an outlook object and put it over the listview it does execute. So is there a way for excel to save that object since it cannot currently use it? It would save it as a msg file by default I would think. I am still trying to figure out a way to use that drag drop feature.[/FONT]
 
Upvote 0
Not that I'm aware of. As I said earlier, VB(A) has no concept of the data format being passed in,
 
Upvote 0
Not that I'm aware of. As I said earlier, VB(A) has no concept of the data format being passed in,

I have decided to just develop the outlook emails directly into the userform and just keep an active outlook application hidden in the background. I am just curious is there a way to track events that occur in an outlook application through the excel application it was created from?

thanks
 
Upvote 0
If they're exposed in the Outlook object model then you can probably trap them using one or more variables declared WithEvents, as with most objects.
 
Upvote 0
Hey,

So we found another way to use this to capture the outlook info. Basically we take the current outlook selection when the oledragdrop event occurs. The only issue I am having is the OLEGiveFeedback doesnt seem to fire when I am trying to do some visual effects. My code is as follows:

Code:
Private Sub DragOverImage_BeforeDragOver(ByVal Cancel As MSForms.ReturnBoolean, ByVal Data As MSForms.DataObject, ByVal x As Single, ByVal y As Single, ByVal DragState As MSForms.fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer)
    Me.lvDropEmailHere.Visible = True
End Sub




Private Sub LvDropEmailHere_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
    Me.lvDropEmailHere.Visible = False
End Sub


Private Sub lvDropEmailHere_OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)
    msgbox "test"

End Sub

If someone clicks to drag something on it but then changes their mind and undrags off without letting go of the click. I am trying to make the treeview go invisible again.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,685
Members
448,977
Latest member
dbonilla0331

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top