Outlook 2007 crashed when pushing send on a displayed mailitem

  • Thread starter Thread starter Jeroen
  • Start date Start date
J

Jeroen

Hello,

I have the following problem:

When I display a mailitem and push send Outlook 2007 crashed with no error.
It only happens when Outlook is not started when I execute my code.

It happens on different computers. SP2 is installed.

I use the following code:

var
Outlook : OLEVariant;
MailItem : OleVariant;
MAPI : OleVariant;
Folder : OleVariant;
begin
try
Outlook:=GetActiveOleObject('Outlook.Application') ;
except
Outlook:=CreateOleObject('Outlook.Application') ;
end;

MAPI := Outlook.GetNameSpace('MAPI');
Folder := MAPI.GetDefaultFolder(olFolderOutbox);
MailItem := Folder.Items.Add(olMailItem);

begin
try
MailItem.To := '(e-mail address removed)';
MailItem.Display(false);
except
end;
end; {with}
 
Problem solved by starting Outlook with a ShellExecute and then ask the
handle for the COM object. Somehow starting Outlook through com causes the
exceptio mentioned earlier.
 
Back
Top