Delphi Russian Knowledge Base
DRKB - это самая большая и удобная в использовании база знаний по Дельфи в рунете, составленная Виталием Невзоровым

How to send and receive email


This code activates the Tools|Send and Receive|All accounts menu item:

uses Office_TLB; // Office97 for D5 users
  ToolsMenu: CommandBar;
  SendRecMenuItem, AllAccs: CommandBarControl;
  ToolsMenu := (Outlook.ActiveExplorer.CommandBars as CommandBars).Item['Tools'];
  // D5 users can omit the underscore after 'Controls' in the next two lines
  SendRecMenuItem := ToolsMenu.Controls_['Send and Receive'];
  AllAccs := (SendRecMenuItem.Control as CommandBarPopup).Controls_['All Accounts'];

If you're using Outlook 2000, you'll have to change 'Send and Receive', perhaps to 'Send/Receive'. (I've had one report that this works, one that it doesn't - perhaps there are spaces around the '/'? Any clarification of this would be very welcome! Pointless menu changes don't make automation any easier...)