I had no problem running rthe script below (I used OutlookSpy - click "Script Editor" button, paste the script, click Run) What is your version of Outlook? What happens if you declare spMailItem as IDispatch instead of _MailItemPtr? Note that your code will fail if you encounter an item other than MailItem (such as ReportItem).
set Folder = Application.ActiveExplorer.CurrentFolder set Items = Folder.Items Items.SetColumns("SenderName") for each Item in Items Debug.Print Item.SenderName next
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool
"Ivan" <Ivan[ at ]discussions.microsoft.com> wrote in message news:2DA20E41-8A48-4AAC-87C0-0E636026D1EC[ at ]microsoft.com...
[Quoted Text] > // spFolder - MAPIFolderPtr > _ItemsPtr spItems = spFolder->Items; > spItems->SetColumns( "SenderName" ); > for (int j = 0; j < spItems->Count; j++) > { > _MailItemPtr spMailItem = spItems->Item( j+1 ); > // spMailItem == null always, but without calling SetColumns everything > is ok. > > if ( !spMailItem ) > continue; > } > spItems->ResetColumns();
|