title: Delphi Read Email with Outlook Automation
body: <p>I have a running code which I can use to read the email body text .The problem is I would like to move the mails that I read. Forexample I read the mail in inbox and I want to move it to another folder in Outlook. After searchin I can do that with Move command but my program gives error "Array out of bounds ".
  For example I have 4 emails in Outlook inbox it only moves 2 files and gives this error.
  What is wrong in my code? Please help Thanks</p>
  
  <pre><code>try
  ovOutlook := CreateOleObject('Outlook.Application');
  ovNameSpace := ovOutlook.GetNameSpace('MAPI');
  ovNameSpace.Logon('', '', False, True);
  ovFolder := ovNameSpace.GetDefaultFolder(olFolderInbox);
  OtherFolder:=ovFolder.Parent.Folders('BTM');
  deger:= ovFolder.items.count;
  for ii := 1 to deger do begin
   if VarIsNull(ovFolder.Items[ii]) or VarIsEmpty(ovFolder.Items[ii])  then Continue;
    ovEmailItem := ovNameSpace.GetItemFromID(ovFolder.Items[ii].EntryID);
    ovFolder.Items[ii].Move(otherfolder);
  end;
  finally
  ovEmailItem := Unassigned;
  ovOutlook := Unassigned;
  ovNameSpace := Unassigned;
  ovFolder := Unassigned;
  OtherFolder :=   Unassigned;
  end;
  </code></pre>