there is runtime error with some assembler code window displayed.
I can't answer that, as I don't use FreePascal myself. You will just have to debug the code for yourself and find out why it is crashing. However, I will say that COM expects
BSTR strings, not Pascal strings, so try casting your strings to
WideString (a wrapper for
BSTR) when passing them to COM, eg:
procedure send_email(r, s, b: String);
const
olMailItem = 0;
olByValue = 1;
var
OutlookApp, MailItem: OLEVariant;
begin
try
OutlookApp := GetActiveOleObject('Outlook.Application');
except
OutlookApp := CreateOleObject('Outlook.Application');
end;
try
MailItem := OutlookApp.CreateItem(olMailItem);
try
MailItem.Recipients.Add(WideString(r));
MailItem.Subject := WideString(s);
MailItem.Body := WideString(b);
MailItem.Send;
finally
MailItem := VarNull;
end;
finally
OutlookApp := VarNull;
end;
end;
On a side note, you do not need to explicitly set
OLEVariant to null when you are done using it. It is managed by the compiler and will be cleaned up automatically when it goes out of scope, eg:
procedure send_email(r, s, b: String);
const
olMailItem = 0;
olByValue = 1;
var
OutlookApp, MailItem: OLEVariant;
begin
try
OutlookApp := GetActiveOleObject('Outlook.Application');
except
OutlookApp := CreateOleObject('Outlook.Application');
end;
MailItem := OutlookApp.CreateItem(olMailItem);
MailItem.Recipients.Add(WideString(r));
MailItem.Subject := WideString(s);
MailItem.Body := WideString(b);
MailItem.Send;
end;