Drag&Drop from Outlook (Express) - Possible?

Just starting out? Need help? Post your questions and find answers here.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post 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!
PureBasic for Windows
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post 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
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone! ;)"
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post 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
PureBasic for Windows
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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....;)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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! :)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

Hi Saprkie,

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

thanx
Marco
PureBasic for Windows
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Has there been any luck with dragging messages and attachments from Outlook to PB? Pure Outlook rather than Outlook Express.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Re:

Post 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
PureBasic for Windows
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

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

Post 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
ImageThe happiness is a road...
Not a destination
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

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

Post by Marco2007 »

What? Sky?
What do you mean?
PureBasic for Windows
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

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

Post by LuCiFeR[SD] »

Marco2007 wrote:What? Sky?
What do you mean?
He means like how Gotham City call for Batman LOL :)

Image
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

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

Post 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
ImageThe happiness is a road...
Not a destination
mesozorn
Enthusiast
Enthusiast
Posts: 171
Joined: Fri Feb 20, 2009 2:23 am

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

Post 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?
mesozorn
Enthusiast
Enthusiast
Posts: 171
Joined: Fri Feb 20, 2009 2:23 am

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

Post 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....
Post Reply