Find sender and subject and delete

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

Find sender and subject and delete
 
Jon Channon




Posts: 1
Joined: 2006-11-15
For Outlook: Is it possible to search the deleted items folder for emails from a certain address and subject and then delete the emails it finds?

If so could you provide some sample code? Gratefully received!

Thanks

Jon
Posted 15 Nov, 2006 11:51:31 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Jon,

See the code below:

uses Outlook2000;

procedure TAddInModule.TAddInModule.adxOlExplorerCommandbar1Controls0Click(Sender: TObject);
var
  i: Integer;
  IFolder: MAPIFolder;
  IMail: _MailItem;
  Subject, SenderName: WideString;
begin
  IFolder := OutlookApp.GetNamespace('MAPI').GetDefaultFolder(olFolderDeletedItems);
  if Assigned(IFolder) then
    try
      for i := IFolder.Items.Count downto 1 do begin
        IFolder.Items.Item(i).QueryInterface(IID__MailItem, IMail);
        if Assigned(IMail) then
          try
            Subject := IMail.Subject;
            SenderName := IMail.SenderName;
            //TODO
            //if (Subject = '') and (SenderName = '') then IMail.Delete;
          finally
            IMail := nil;
          end;
      end;
    finally
      IFolder := nil;
    end;
end;


P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.
Posted 16 Nov, 2006 05:23:44 Top