Menu

D&D of Outlook attachments

Help
Anonymous
2011-06-17
2013-04-26
  • Anonymous

    Anonymous - 2011-06-17

    Hiyas

    This project looks kinda interesting. A question though: how is D&D from attachments of Outlook into a Java application solved? The testprograms only seem to work if the whole message is dropped into a Java application. From there on, a .MSG file is created (or the link to it returned). Is it supposed to read the MSG file and parse the attachments from there one or how is it supposed to work? Is directly dragging and dropping an attachment from Outlook to Java supported?

     
  • wide

    wide - 2011-06-19

    Hello,

    in order to D&D an attachment, you have to open the mail (double click) in outlook at first. Then select the attachments tab and drag it onto the test dialog. That's the way it works for me. You will receive an InputStream (MODE_MEMORY_STREAMS, OutlookItem.getContent ) or a temp file (MODE_TEMP_FILES) for the attachment.

    If you want to parse an MSG file, you may want to use the Apache POI library: http://poi.apache.org/hsmf/

    Regards

     
  • Peter Guy

    Peter Guy - 2011-09-06

    I'm able to drag and drop attachments when using Outlook 2007 SP2 on Windows 7 (1.6.0_24 JRE), both from the preview and from the message.  However, I am not able to drag and drop attachments from Outlook 2003 SP3 on XP (1.60_26 JRE), either in preview or when viewing the message.  I'm using MODE_MEMORY_STREAMS.  I had to install the Visual Studio 2010 redistributable on XP, but Visual C++ Express 2010 was already installed on Windows 7, so I didn't need the redistributable for it.

    I'm fair to middling with C++/MFC and have written some of my own JNI libraries, so I'm picking my way through the source.  If I find anything, I'll post it back to the project.

    tl;dr warning: following are the log entries for my two test setups. :-)

    Here's the log file output from Outlook 2003 SP3 on XP:

    2011-09-06 21:40:34.375 [00780] RegisterDataFormats(
    2011-09-06 21:40:34.375 [00780] file contents format =49390
    2011-09-06 21:40:34.375 [00780] file group descriptor format =49392
    2011-09-06 21:40:34.375 [00780] )RegisterDataFormats
    2011-09-06 21:41:02.484 [02932] setDataObject(13DF62B0, isDrop=0
    2011-09-06 21:41:02.484 [02932] dumpFormats(
    2011-09-06 21:41:02.484 [02932]  cfFormat=49391 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:02.484 [02932]  cfFormat=49757 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:02.484 [02932]  cfFormat=49390 dwAspect=1 tymed=4 lindex=0 pdt=00000000
    2011-09-06 21:41:02.484 [02932]  cfFormat=1 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:02.484 [02932]  cfFormat=13 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:02.484 [02932] )dumpFormats
    2011-09-06 21:41:02.484 [02932] CF_HDROP avail=0
    2011-09-06 21:41:02.484 [02932] getFileGroupDescriptorFromDataObject(
    2011-09-06 21:41:02.484 [02932] pDataObject=13DF62B0
    2011-09-06 21:41:02.484 [02932] GetData...
    2011-09-06 21:41:02.484 [02932] GetData=-2147221404
    2011-09-06 21:41:02.484 [02932] )getFileGroupDescriptorFromDataObject=00000000
    2011-09-06 21:41:02.484 [02932] )setDataObject=13DF62B0
    2011-09-06 21:41:02.953 [00780] Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail(
    2011-09-06 21:41:02.953 [00780] pDropTarget=14B74D80
    2011-09-06 21:41:02.953 [00780] )Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail=0
    2011-09-06 21:41:02.953 [00780] Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail(
    2011-09-06 21:41:02.953 [00780] pDropTarget=14B74D80
    2011-09-06 21:41:02.953 [00780] )Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail=0
    ...
    2011-09-06 21:41:03.468 [02932] setDataObject(13DF62B0, isDrop=1
    2011-09-06 21:41:03.468 [02932] dumpFormats(
    2011-09-06 21:41:03.468 [02932]  cfFormat=49391 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:03.468 [02932]  cfFormat=49757 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:03.468 [02932]  cfFormat=49390 dwAspect=1 tymed=4 lindex=0 pdt=00000000
    2011-09-06 21:41:03.468 [02932]  cfFormat=1 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:03.468 [02932]  cfFormat=13 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:03.468 [02932] )dumpFormats
    2011-09-06 21:41:03.468 [02932] IDataObject proxy=13DF62B0
    2011-09-06 21:41:03.468 [02932] )setDataObject=13DF62B0
    2011-09-06 21:41:03.468 [00780] Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail(
    2011-09-06 21:41:03.468 [00780] pDropTarget=14B74D80
    2011-09-06 21:41:03.468 [00780] )Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail=0
    ...
    

    And the log file from Outlook 2007 on Windows 7:

    2011-09-06 21:52:46.987 [06468] RegisterDataFormats(
    2011-09-06 21:52:46.987 [06468] file contents format =49378
    2011-09-06 21:52:46.987 [06468] file group descriptor format =49380
    2011-09-06 21:52:46.987 [06468] )RegisterDataFormats
    2011-09-06 21:53:23.740 [06436] setDataObject(00624918, isDrop=0
    2011-09-06 21:53:23.740 [06436] dumpFormats(
    2011-09-06 21:53:23.740 [06436]  cfFormat=49380 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:53:23.740 [06436]  cfFormat=49379 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:53:23.740 [06436]  cfFormat=49683 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:53:23.740 [06436]  cfFormat=49378 dwAspect=1 tymed=4 lindex=0 pdt=00000000
    2011-09-06 21:53:23.740 [06436] )dumpFormats
    2011-09-06 21:53:23.740 [06436] CF_HDROP avail=0
    2011-09-06 21:53:23.740 [06436] getFileGroupDescriptorFromDataObject(
    2011-09-06 21:53:23.740 [06436] pDataObject=00624918
    2011-09-06 21:53:23.740 [06436] GetData...
    2011-09-06 21:53:23.740 [06436] GetData=0
    2011-09-06 21:53:23.740 [06436] GlobalSize ... hGlobal=18EC00B4
    2011-09-06 21:53:23.740 [06436] GlobalSize=596
    2011-09-06 21:53:23.740 [06436] GlobalAlloc ... size=596
    2011-09-06 21:53:23.740 [06436] GlobalAlloc=18EC00BC
    2011-09-06 21:53:23.740 [06436] copy bytes ...
    2011-09-06 21:53:23.740 [06436] copy bytes OK
    2011-09-06 21:53:23.740 [06436] ReleaseStgMedium...
    2011-09-06 21:53:23.740 [06436] ReleaseStgMedium OK
    2011-09-06 21:53:23.740 [06436] )getFileGroupDescriptorFromDataObject=18EC00BC
    2011-09-06 21:53:23.740 [06436] MODE_TEMP_FILE=0
    2011-09-06 21:53:23.740 [06436] )setDataObject=00624918
    2011-09-06 21:53:24.208 [06468] Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail(
    2011-09-06 21:53:24.208 [06468] pDropTarget=1CB36D58
    2011-09-06 21:53:24.208 [06468] )Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail=1
    2011-09-06 21:53:24.208 [06468] Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail(
    2011-09-06 21:53:24.208 [06468] pDropTarget=1CB36D58
    2011-09-06 21:53:24.208 [06468] )Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail=1
    ...
    2011-09-06 21:53:24.613 [06436] setDataObject(00624918, isDrop=1
    2011-09-06 21:53:24.613 [06436] dumpFormats(
    2011-09-06 21:53:24.613 [06436]  cfFormat=49380 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:53:24.613 [06436]  cfFormat=49379 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:53:24.613 [06436]  cfFormat=49683 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:53:24.613 [06436]  cfFormat=49378 dwAspect=1 tymed=4 lindex=0 pdt=00000000
    2011-09-06 21:53:24.613 [06436] )dumpFormats
    2011-09-06 21:53:24.613 [06436] IDataObject proxy=00624918
    2011-09-06 21:53:24.613 [06436] )setDataObject=00624918
    2011-09-06 21:53:24.613 [06468] Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail(
    2011-09-06 21:53:24.613 [06468] pDropTarget=1CB36D58
    2011-09-06 21:53:24.613 [06468] )Java_de_wim_outldd_OutlDDNativeLib_isOutlookDataAvail=1
    ...
    2011-09-06 21:53:24.629 [06468] Java_de_wim_outldd_OutlDDNativeLib_getFileGroupDescriptor(
    2011-09-06 21:53:24.629 [06468] pDropTarget=1CB36D58
    2011-09-06 21:53:24.629 [06468] makeInputStreamFromHGLOBAL(1CB37698
    2011-09-06 21:53:24.629 [06468] classStrm=1939AEE0
    2011-09-06 21:53:24.629 [06468] call constructor, methodID=1CF741BC
    2011-09-06 21:53:24.629 [06468] call constructor, strm=1939AEDC
    2011-09-06 21:53:24.629 [06468] )makeInputStreamFromHGLOBAL=1939AEDC
    2011-09-06 21:53:24.629 [06468] )Java_de_wim_outldd_OutlDDNativeLib_getFileGroupDescriptor=1939AEDC
    2011-09-06 21:53:24.629 [06468] Java_de_wim_outldd_OutlDDNativeLib_getText(
    2011-09-06 21:53:24.645 [06468] invokeInAwtToolkitThread ... 
    2011-09-06 21:53:24.645 [06468] invokeInAwtToolkitThread(ftn=677C9F10, param=00000000
    2011-09-06 21:53:24.645 [06468] getToolkitWindow(
    2011-09-06 21:53:24.645 [06468] subclass
    2011-09-06 21:53:24.645 [06468] )getToolkitWindow=000A0A72
    2011-09-06 21:53:24.645 [06468] hwndToolkit=000A0A72
    2011-09-06 21:53:24.645 [06468] MethodParam::MethodParam(
    2011-09-06 21:53:24.645 [06468] CreateEvent hReadyEvent=000009F4
    2011-09-06 21:53:24.645 [06468] )MethodParam::MethodParam
    2011-09-06 21:53:24.645 [06468] methodParam=1CB376B0
    2011-09-06 21:53:24.645 [06468] hReadyEvent000009F4
    2011-09-06 21:53:24.645 [06468] PostMessage...
    2011-09-06 21:53:24.645 [06468] PostMessage, win-err=0
    2011-09-06 21:53:24.645 [06436] g_toolkitWindowProc.WM_MY_INVOKE_METHOD(
    2011-09-06 21:53:24.645 [06468] WaitForMultipleObjects ... 000009F4
    2011-09-06 21:53:24.645 [06436] methodParam=1CB376B0
    2011-09-06 21:53:24.645 [06436] invokeMethod(1CB376B0
    2011-09-06 21:53:24.645 [06436] getTextFromDataObjectVoid(00000000
    2011-09-06 21:53:24.645 [06436] pDropTarget=1CB36D58
    2011-09-06 21:53:24.645 [06436] pDataObject=00624918
    2011-09-06 21:53:24.645 [06436] getText...
    2011-09-06 21:53:24.645 [06436] getText(00624918
    2011-09-06 21:53:24.645 [06436] GetData ... 
    2011-09-06 21:53:24.645 [06436] GetData=-2147221404
    2011-09-06 21:53:24.645 [06436] )getText=-2147221404
    2011-09-06 21:53:24.645 [06436] getText=-2147221404, hMem=00000000
    2011-09-06 21:53:24.645 [06436] )getTextFromDataObjectVoid=00000000
    2011-09-06 21:53:24.645 [06436] SetEvent hReadyEvent=000009F4
    2011-09-06 21:53:24.645 [06436] )invokeMethod
    2011-09-06 21:53:24.645 [06468] WaitForMultipleObjects, ret=0, hReadyEvent=000009F4
    2011-09-06 21:53:24.645 [06436] )g_toolkitWindowProc.WM_MY_INVOKE_METHOD
    2011-09-06 21:53:24.645 [06468] ~MethodParam::MethodParam(
    2011-09-06 21:53:24.645 [06468] CloseEvent hReadyEvent=000009F4
    2011-09-06 21:53:24.645 [06468] )MethodParam::MethodParam
    2011-09-06 21:53:24.645 [06468] )invokeInAwtToolkitThread=00000000
    2011-09-06 21:53:24.645 [06468] invokeInAwtToolkitThread OK, hMem=00000000
    2011-09-06 21:53:24.645 [06468] )Java_de_wim_outldd_OutlDDNativeLib_getText=00000000
    2011-09-06 21:53:24.645 [06468] Java_de_wim_outldd_OutlDDNativeLib_getFileContent(fileIndex=0
    2011-09-06 21:53:24.645 [06468] invokeInAwtToolkitThread(ftn=677C8CB0, param=1C43EE40
    2011-09-06 21:53:24.645 [06468] hwndToolkit=000A0A72
    2011-09-06 21:53:24.645 [06468] MethodParam::MethodParam(
    2011-09-06 21:53:24.645 [06468] CreateEvent hReadyEvent=000009F4
    2011-09-06 21:53:24.645 [06468] )MethodParam::MethodParam
    2011-09-06 21:53:24.645 [06468] methodParam=1CB376B0
    2011-09-06 21:53:24.645 [06468] hReadyEvent000009F4
    2011-09-06 21:53:24.645 [06468] PostMessage...
    2011-09-06 21:53:24.645 [06468] PostMessage, win-err=0
    2011-09-06 21:53:24.645 [06468] WaitForMultipleObjects ... 000009F4
    2011-09-06 21:53:24.645 [06436] g_toolkitWindowProc.WM_MY_INVOKE_METHOD(
    2011-09-06 21:53:24.645 [06436] methodParam=1CB376B0
    2011-09-06 21:53:24.645 [06436] invokeMethod(1CB376B0
    2011-09-06 21:53:24.645 [06436] getFileContentFromDataObjectVoid(1C43EE40
    2011-09-06 21:53:24.645 [06436] fileIndex=0
    2011-09-06 21:53:24.645 [06436] pDropTarget=1CB36D58
    2011-09-06 21:53:24.645 [06436] pDataObject=00624918
    2011-09-06 21:53:24.645 [06436] getFileContentFromDataObject(fileIndex=0
    2011-09-06 21:53:24.645 [06436] pDataObject=00624918
    2011-09-06 21:53:24.645 [06436] GetData ... 
    2011-09-06 21:53:24.660 [06436] GetData=0
    2011-09-06 21:53:24.660 [06436] stgmedium.tymed4
    2011-09-06 21:53:24.660 [06436] TYMED_ISTREAM
    2011-09-06 21:53:24.660 [06436] IStream.Stat...
    2011-09-06 21:53:24.660 [06436] IStream.Stat=0
    2011-09-06 21:53:24.660 [06436] GlobalAlloc ... size=18944
    2011-09-06 21:53:24.660 [06436] GlobalAlloc ... hGlobal=18EC00B4
    2011-09-06 21:53:24.660 [06436] GlobalLock ... hGlobal=18EC00B4
    2011-09-06 21:53:24.660 [06436] GlobalLock=201678E0
    2011-09-06 21:53:24.660 [06436] IStream.Read buf=201678E0, size=18944
    2011-09-06 21:53:24.660 [06436] IStream.Read=0, cbRead=18944
    2011-09-06 21:53:24.660 [06436] GlobalUnlock ... hGlobal=18EC00B4
    2011-09-06 21:53:24.660 [06436] GlobalUnlock
    2011-09-06 21:53:24.660 [06436] ReleaseStgMedium...
    2011-09-06 21:53:24.660 [06436] ReleaseStgMedium OK
    2011-09-06 21:53:24.660 [06436] )getFileContentFromDataObject=18EC00B4
    2011-09-06 21:53:24.660 [06436] )getFileContentFromDataObject=18EC00B4
    2011-09-06 21:53:24.660 [06436] SetEvent hReadyEvent=000009F4
    2011-09-06 21:53:24.660 [06436] )invokeMethod
    2011-09-06 21:53:24.660 [06436] )g_toolkitWindowProc.WM_MY_INVOKE_METHOD
    2011-09-06 21:53:24.660 [06468] WaitForMultipleObjects, ret=0, hReadyEvent=000009F4
    2011-09-06 21:53:24.660 [06468] ~MethodParam::MethodParam(
    2011-09-06 21:53:24.660 [06468] CloseEvent hReadyEvent=000009F4
    2011-09-06 21:53:24.660 [06468] )MethodParam::MethodParam
    2011-09-06 21:53:24.660 [06468] )invokeInAwtToolkitThread=18EC00B4
    2011-09-06 21:53:24.660 [06468] makeInputStreamFromHGLOBAL(1CB376B0
    2011-09-06 21:53:24.660 [06468] classStrm=1939AEC0
    2011-09-06 21:53:24.660 [06468] call constructor, methodID=1CF741BC
    2011-09-06 21:53:24.660 [06468] call constructor, strm=1939AEC4
    2011-09-06 21:53:24.660 [06468] )makeInputStreamFromHGLOBAL=1939AEC4
    2011-09-06 21:53:24.660 [06468] )Java_de_wim_outldd_OutlDDNativeLib_getFileContent=1939AEC4
    
     
  • wide

    wide - 2011-09-07

    Hello peterguy,

    as I can see in the log file, you do not use the current version of the DLL. There was a fix in 1.0.0.2  for using embedded attachements which likely solves  your problem too. Since 1.0.0.2 the ANSI version of the FileGroupDescriptor is also evaluated.

    The log file (Outlook 2003) prints the format ID for the UNICODE version of the FileGroupDescriptor:

    file group descriptor format =49392
    

    Some lines below, the contents of the DataObject are shown:

    2011-09-06 21:41:02.484 [02932] dumpFormats(
    2011-09-06 21:41:02.484 [02932]  cfFormat=49391 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:02.484 [02932]  cfFormat=49757 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:02.484 [02932]  cfFormat=49390 dwAspect=1 tymed=4 lindex=0 pdt=00000000
    2011-09-06 21:41:02.484 [02932]  cfFormat=1 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:02.484 [02932]  cfFormat=13 dwAspect=1 tymed=1 lindex=-1 pdt=00000000
    2011-09-06 21:41:02.484 [02932] )dumpFormats
    

    Since there is no line with format=49392, the UNICODE version of the FileGroupDescriptor is not available. Thus the DLL thinks, the DataObject does not come from Outlook.
    Most likely, the format ID 49391 is the ANSI encoded FileGroupDescriptor, but it is only read in later DLL versions.

    Regards
    Wolfgang Imig

     
  • Peter Guy

    Peter Guy - 2011-09-08

    Thanks for the rapid response, Wolfgang!

    I'm embarrassed: First rule of debugging is to make sure one has the newest version, right? :-P

    I figured it had to do with the file group descriptor shell clipboard format.  I saw the same missing format in dumpFormats and I noticed in the version I had (1.0.0.1) that you were using the unicode file description when registering the format, so I was in the process of trying to register the ascii format, too.

    Anyway, I downloaded 1.0.0.4 (I like that you load the dlls from the temp dir now - I've started doing that, too :-) ), scrubbed my system of all traces of the old jar and dll, and tried it again.  Success!

    Thanks so much; pretty cool project you've got here! :-)

    -Peter

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.