Drag and drop Outlook and/or Groupwise email

Is there a way to drag and drop an email message from Outlook and/or Groupwise into my D5 application?  If so, any pointers (no pun intended) on how to do it?
bjones8888PresidentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee_NoverCommented:
yes..  with OLE d&d
register a control as a droptarget with RegisterDragDrop :)
you'll need to implement IDropTarget
then in the implementation handle the IDataObject

here's a starter helper unit to get a list of files from an IDataObject

you'll need to figure out what kind of data Outlook "drags" and handle it
it probably provides a few formats



{-----------------------------------------------------------------------------
 Unit Name: DragDropHelpers
 Author:    Lee_Nover
 Date:      2004.10.26
 Purpose:   Helper functions for OLE Drag&Drop
 Copyright: Lee_Nover - Lee_Nover@delphi-si.com
 History:
  2004.10.26
    first implementation
    ReadFilesFrom* functions are taken from Drag&Drop suite:
      Drag and Drop Component Suite Version 4.0
      Released 18-may-2001
      © 1997-2001 Angus Johnson & Anders Melander

-----------------------------------------------------------------------------}
unit DragDropHelpers;

interface

uses Classes, ActiveX;

function FilesFromIDataObject(ADataObject: IDataObject; AFiles: TStrings): Integer;

implementation

uses Windows, ShlObj;

function ReadFilesFromZeroList(Data: pointer; Size: integer;
  Wide: boolean; Files: TStrings): boolean;
var
  StringSize: Integer;
begin
  Result := False;
  if (Data <> nil) then
    while (Size > 0) and (PChar(Data)^ <> #0) do
    begin
      if (Wide) then
      begin
        Files.Add(PWideChar(Data));
        StringSize := (Length(PWideChar(Data)) + 1) * 2;
      end else
      begin
        Files.Add(PChar(Data));
        StringSize := Length(PChar(Data)) + 1;
      end;
      inc(PChar(Data), StringSize);
      dec(Size, StringSize);
      Result := True;
    end;
end;

function ReadFilesFromData(Data: pointer; Size: integer; Files: TStrings): boolean;
var
  Wide: boolean;
begin
  Files.Clear;
  if (Data <> nil) then
  begin
    Wide := PDropFiles(Data)^.fWide;
    dec(Size, PDropFiles(Data)^.pFiles);
    inc(PChar(Data), PDropFiles(Data)^.pFiles);
    ReadFilesFromZeroList(Data, Size, Wide, Files);
  end;

  Result := (Files.Count > 0);
end;

function ReadFilesFromHGlobal(const HGlob: HGlobal; Files: TStrings): boolean;
var
  DropFiles: PDropFiles;
begin
  DropFiles := PDropFiles(GlobalLock(HGlob));
  try
    Result := ReadFilesFromData(DropFiles, GlobalSize(HGlob), Files)
  finally
    GlobalUnlock(HGlob);
  end;
end;

function FilesFromIDataObject(ADataObject: IDataObject; AFiles: TStrings): Integer;
var
  I: Integer;
  Data: TStgMedium;
  SOF: TFormatEtc;
  Enum: IEnumFORMATETC;
begin
  Result:=0;
  if ADataObject = nil then
    exit;

  ZeroMemory(@Data, SizeOf(Data));
  ADataObject.EnumFormatEtc(DATADIR_GET, Enum);
  while (Enum.Next(1, SOF, @I) = S_OK) and (I > 0) do
    if SOF.cfFormat = CF_HDROP then
    begin
      if Succeeded(ADataObject.GetData(SOF, Data)) then
      try
        case SOF.tymed of
          TYMED_FILE: AFiles.Text:=Data.lpszFileName;
          TYMED_HGLOBAL: ReadFilesFromHGlobal(Data.hGlobal, AFiles);
          else exit;
        end;
        Result:=AFiles.Count;
        exit;
      finally
        ReleaseStgMedium(Data);
      end;
    end;
end;

end.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bjones8888PresidentAuthor Commented:
Wow.  Some of this is beyond my current Delphi experience.  Can you email me? (bob@cycominc.com)  
Thanks.
0
Lee_NoverCommented:
although the comment was accepted we can continue the conversation here ... which I'd prefer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.