Downloadstate late binding

Add-in Express™ Support Service
That's what is more important than anything else

Downloadstate late binding
 
Spiros Nikolopoulos




Posts: 42
Joined: 2012-01-05
I want to use the Downloadstate of IMailItem but I'm using outlook2000 unit.
Are there any example to late bind the Downloadstate ?
Posted 15 Nov, 2012 13:08:17 Top
Andrei Smolin


Add-in Express team


Posts: 15192
Joined: 2006-05-11
Hi Spiros,

You can use late binding. Also, you can import the type library of Outlook 2002. See also http://www.add-in-express.com/forum/read.php?FID=1&TID=8505.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 16 Nov, 2012 03:09:05 Top
Spiros Nikolopoulos




Posts: 42
Joined: 2012-01-05
Thanks It worked with late binding.

When a user clicks on a message outlook downloads the rest of the message with attachments (it is configured to download only headers from imap server).
Is it possible to wait and reload the selected message when it is fully downloaded ?

Thanks
Posted 18 Nov, 2012 06:06:26 Top
Andrei Smolin


Add-in Express team


Posts: 15192
Joined: 2006-05-11
Hi Spiros,

At http://social.msdn.microsoft.com/Forums/bg-BG/outlookdev/thread/6e094a14-28de-4291-a3d5-4a53af4fcdc4, Ken Slovak suggests:


I suppose you could try setting the MarkForDownload property to olMarkedForDownload and then do a send/receive, but that's expensive for performance and would end up not providing the full item until the send/receive was finished. Or you could get the item and try using GetInspector to possibly fill it in.


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 19 Nov, 2012 05:41:17 Top
Spiros Nikolopoulos




Posts: 42
Joined: 2012-01-05
Andrei,

I found that Slovak's suggestion link in this forum.
What I was thinking is, since the "reading pane" of outlook it is opened, when the user clicks on a message this message automatically starts to download.All I need is a mechanism to wait for the message to download.
Checking the Downloadstate inside a loop , waiting for it to change, doesn't work because then Downloadstate
won't change. I have to click the mail in the explorer again or somehow re-read the mailItem inside the loop ...
Posted 19 Nov, 2012 06:02:45 Top
Andrei Smolin


Add-in Express team


Posts: 15192
Joined: 2006-05-11
Hi Spiros,

I suppose that you do this in two steps: 1) you get the item and 2) you check its DownloadState in a loop. If so, I suggest trying to do this in this way: in a loop, you [re-]get the item and check its DownloadState.

Note that the way suggested by Ken Slovak should work even if the Reading Pane is closed.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 19 Nov, 2012 06:18:37 Top
Spiros Nikolopoulos




Posts: 42
Joined: 2012-01-05
OK I think I did it but the DownloadState still remains 0.
The problem is in re-getting the item.
selectionItem := Nil;
mlItem := Nil;
is not enough in the following code?

                  if OleVariant(mlItem).DownloadState = 0 then
                    Begin
                      repeat                  
                         selectionItem := Nil; 
                         mlItem := Nil;
                         selectionItem := OutlookUtils.GetExplorerSelectionItem(self.ExplorerObj,SelectedItems);
                         selectionItem.QueryInterface(IID__MailItem, mlItem);
                      until OleVariant(mlItem).DownloadState = 1;
                    End;
Posted 19 Nov, 2012 10:24:12 Top
Andrei Smolin


Add-in Express team


Posts: 15192
Joined: 2006-05-11
Hi Spiros,

I suppose you also need to re-get SelectedItems.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 19 Nov, 2012 10:33:25 Top
Spiros Nikolopoulos




Posts: 42
Joined: 2012-01-05

                      repeat
                        selectionItem := Nil;
                        mlItem        := Nil;
                        SelectedItems := Nil;
                        AExplorer     := Nil;

                        AExplorer := self.ExplorerObj;

                        selectionItem := OutlookUtils.GetExplorerSelectionItem(AExplorer,SelectedItems);
                        selectionItem.QueryInterface(IID__MailItem, mlItem);

                      until OleVariant(mlItem).DownloadState = 1;


the GetExplorerSelectionItems re-gets the selectedItems but still no change to the DowloadState



class function OutlookUtils.GetExplorerSelectionItem(AExplorer: Explorer;var SelectedItems:SelectedItemsType): IDispatch;
var
  sel: Selection;
  i  : Integer;

begin
  result := nil;

  sel := AExplorer.Selection;
  try
    if (sel.Count > 0) then begin
      result := sel.Item(1);

      setlength(SelectedItems,sel.Count);
      for i := 0 to sel.Count-1 do
        selectedItems[i] := sel.item(i+1);

    end;
  finally
    sel := nil;
  end;
end;
Posted 20 Nov, 2012 04:55:00 Top
Dmitry Kostochko


Add-in Express team


Posts: 2742
Joined: 2004-04-05
Hi Spiros,

Sorry, I cannot suggest any other solution at the moment. Probably you could try to use the TTimer component to check the email's state in a little time span.
Posted 20 Nov, 2012 07:16:06 Top