Outlook 2007 crashed when pushing send on a displayed mailitem

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}
 
J

Jeroen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top