I have the following code in my test Delphi 2006 BDS application:
procedure TForm1.Button1Click(Sender: TObject); const olMailItem = 0; var Outlook: OleVariant; vMailItem: variant; begin Outlook := CreateOleObject('Outlook.Application'); vMailItem := Outlook.CreateItem(olMailItem); try vMailItem.Recipients.add('[email protected]'); vMailItem.Display(True); -- outlook mail message is displayed modally except end; VarClear(Outlook); end;
I need to be able to detect whether the user sent the email from within the outlook screen. I tried the following code:
if vMailItem.Sent then ...
But received the error message 'The item has been moved or deleted'. I presume this is because the mail item has moved to the sent items folder. What is the best way to detect if the user sent the email? Also, if the user did send the email then I would also need to be able to view the email body.
Thanks in advance.