Page 2 of 7

Posted: Mon May 12, 2008 8:36 pm
by Marco2007
It looks like Outlook (msg) is a little different. I don`t get it :cry:

...but I will try til I got it!

Posted: Tue May 13, 2008 12:29 am
by Sparkie
Sorry Marco but I do not have Outlook here so I can't be of much help in that respect. Try running the code below and let me know what happens. I think Outlook should use the #CFSTR_FILECONTENTS which should enable you to get the actual message.

Code: Select all

Structure _FILEDESCRIPTOR
  dwFlags.l
  clsid.CLSID
  sizel.SIZE
  pointl.POINT
  dwFileAttributes.l
  ftCreationTime.FILETIME 
  ftLastAccessTime.FILETIME 
  ftLastWriteTime.FILETIME 
  nFileSizeHigh.l
  nFileSizeLow.l
  cFileName.c[#MAX_PATH]
EndStructure

Structure _FILEGROUPDESCRIPTOR
  cItems.l
  fgd._FILEDESCRIPTOR[0]
EndStructure
  
If OpenWindow(0, 0, 0, 700, 500, "Drag 'n' drop",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
  ListIconGadget(1,  10, 10, 680, 100, "Drop Email here", 730)
  cf_email = RegisterClipboardFormat_("Internet Message (rfc822/rfc1522)")
  cf_content = RegisterClipboardFormat_(#CFSTR_FILECONTENTS) 
  cf_descrip = RegisterClipboardFormat_(#CFSTR_FILEDESCRIPTOR)
  EnableGadgetDrop(1, cf_email, #PB_Drag_Copy)
  EnableGadgetDrop(1, cf_content, #PB_Drag_Copy)
  EnableGadgetDrop(1, cf_descrip, #PB_Drag_Copy)
  EditorGadget(2, 10, 120, 680, 400) 
  
  Repeat 
    event = WaitWindowEvent()
    If event = #PB_Event_GadgetDrop And EventGadget() = 1
      Select EventDropType()
        Case cf_email
          ClearGadgetItemList(1)
          ClearGadgetItemList(2)
          *buffer = EventDropBuffer()
          msg$ = PeekS(*buffer)
          subject = FindString(msg$, "Subject:", 1) + 9
          eos = FindString(msg$, #CRLF$, subject)
          subject$ = Mid(msg$, subject, eos - subject)
          AddGadgetItem(1, 0, subject$)
          AddGadgetItem(2, 0, PeekS(*buffer))
        Case cf_content
          MessageRequester("Hey", "#CFSTR_FILECONTENTS is working", #PB_MessageRequester_Ok | #MB_ICONINFORMATION)
        Case cf_descrip
          *fgdBuffer._FILEGROUPDESCRIPTOR = EventDropBuffer()
          eml$ = PeekS(@*fgdBuffer\fgd[0]\cFileName)
          AddGadgetItem(1, 0, eml$)
      EndSelect
    EndIf
  Until event = #PB_Event_CloseWindow
EndIf 
End

Posted: Tue May 13, 2008 1:45 pm
by Thalius
One thing: Why does this (attachments) work with Writestring? I always thought, Writestring makes only sense with strings....
Mail just uses Strings ;). Attachmnets are just Base64/Mime Encoded into Text - thats why WriteString() ;)

this should help on some infos:

RFC822:
http://www.w3.org/Protocols/rfc822/

Thalius

Posted: Tue May 13, 2008 7:19 pm
by Marco2007
Hi Sparkie,

1. thanx for your effort. How embarrassing! I hope, I´m not turning nasty.

2. This one gives me the filename:

Code: Select all

eml$ = PeekS(@*fgdBuffer\fgd[0]\cFileName)
:shock:

That`s not easy...the structures I use, are pretty easy (like the PB-samples - the easy ones with no Poniters, ..).
Have you an idea, how I get the whole message, so I can writestring it?
Well, I know, you ain`t got Outlook...

3. @Thalius: Thanx you for the explanation!

thx
Marco

Posted: Tue May 13, 2008 11:34 pm
by Sparkie
Marco2007 wrote:1. thanx for your effort. How embarrassing! I hope, I´m not turning nasty.
No need for embarassment Marco, I don't mind helping you figure this out.
Marco2007 wrote:Have you an idea, how I get the whole message, so I can writestring it?
Yes and no as it involves digging a little deeper. It's not going to be easy since I do not have Outlook to do my trial and errors. There is still hope because Outlook Express has an alternative method for getting the messages but it's a lot more involved. If I can get it to work it should also work for Outlook...I think...I hope....;)

Posted: Fri May 16, 2008 12:38 pm
by Sparkie
Marco, Google around for IDataObject as well as IStorage for viewing Outlook messages. My not having Outlook to work with makes it near impossible for me to continue any further. Good Luck! :)

Posted: Fri May 16, 2008 4:50 pm
by Marco2007
Hi Saprkie,

yesterday I did find some stuff about that....that`s pretty heavy stuff. I will try...

thanx
Marco

Posted: Thu Jul 02, 2009 7:08 pm
by Xombie
Has there been any luck with dragging messages and attachments from Outlook to PB? Pure Outlook rather than Outlook Express.

Re:

Posted: Sun May 08, 2011 8:48 pm
by Marco2007
Hey Sparkie,

almost three years are gone since you posted your great code...and I`m not 100% shure, but Outlook didn`t work at all (iirc).
NOW: I just tried your code again with Outlook 2007, Win7 and PB 4.51 and it seems, your code is also working with Outlook attachments :-) :-)

thank you (again) :-)

@Xombie: Have you tried it again?
http://www.purebasic.fr/english/viewtop ... 86#p243486

Re: Drag&Drop from Outlook (Express) - Possible?

Posted: Mon Nov 19, 2012 6:58 pm
by Kwai chang caine
Much later but i searched this style of code for outlook express, and it's exactely what i need 8)
Great code SPARKIE, i know you are not really on the forum now then you not read this message :( , but it's important to me to thank you when even for your works, and that help us to not forget you :wink:
Perhaps this message call you in the sky and give to you the desire to come, even a little time, in your forum :D
Again thanks, have a good day

AW: Drag&Drop from Outlook (Express) - Possible?

Posted: Mon Nov 19, 2012 7:18 pm
by Marco2007
What? Sky?
What do you mean?

Re: AW: Drag&Drop from Outlook (Express) - Possible?

Posted: Wed Nov 21, 2012 1:56 pm
by LuCiFeR[SD]
Marco2007 wrote:What? Sky?
What do you mean?
He means like how Gotham City call for Batman LOL :)

Image

Re: Drag&Drop from Outlook (Express) - Possible?

Posted: Wed Nov 21, 2012 3:20 pm
by Kwai chang caine
Exactely !! Lucifer have right !!! :wink:
SPARKIE is a super hero 8)
Since i know SPARKIE, i begin to like Batman :D

Re: Drag&Drop from Outlook (Express) - Possible?

Posted: Thu Feb 13, 2014 9:56 pm
by mesozorn
So, with this lovely bit of code as posted above, how does one actually "get at" the data content of the file itself, rather than just the file's name? The FILEDESCRIPTOR structure seems to contain some useful information about the file, but I'm not seeing anything that would allow us to examine the pure data contained within it.

For example, if I drag-and-drop a .PDF attachment received as part of an email message in Outlook, I can get its name alright, but how would I then copy/save that PDF data directly to disk if desired?

Having done a Google search and come up with the following results:

http://www.codeproject.com/Articles/714 ... -97-and-ab
http://www.codeproject.com/Articles/282 ... -Drop-in-C#

...the processes described seem nightmarishly arcane, and even then are only geared toward using C# commands. I don't know what the equivalent operations would be in PureBasic or Windows API, so I'm hoping someone here has a clue about how to do it.

Can this be accomplished?

Re: Drag&Drop from Outlook (Express) - Possible?

Posted: Fri Feb 14, 2014 9:25 pm
by mesozorn
From my continuing foray into this question, it seems that it is likely not possible from within Purebasic. Although the IDataObject needed exists in PB as a defined structure, none of its or MemoryStream's C-type methods such as GetData are available and thus cannot be invoked in order to extract the filecontents desired. A shame since the file data is undoubtedly sitting there somewhere in memory as a stream of some sort, which could be read if only an address pointer could be obtained.

Even CFSTR_FILECONTENTS is never activated by a drag-drop from Outlook, only Filedescriptor which has limited utility in this scenario.

I admit I'm largely unfamiliar with this particular operation up until now, so if I'm just missing something obvious and someone can point me in the right direction, that would be fantastic....