Here is my code:
const
olMailItem = 0;
var
olApp, OlNameSpace, OlItem, rdSafeItem, rdUtils: variant;
begin
olApp:= CreateOleObject ('Outlook.Application');
olNameSpace:= olApp.GetNamespace ('MAPI');
olNameSpace.Logon;
olItem:= olApp.CreateItem (olMailItem);
rdSafeItem:= CreateOleObject ('Redemption.SafeMailItem');
rdSafeItem.Item:= olItem;
rdSafeItem.Subject:= 'Testing';
rdSafeItem.attachments.Add ('c:\windows\win.ini');
rdSafeItem.Recipients.Add ('test@testing.com');
rdSafeItem.Send;
rdUtils:= CreateOleObject ('Redemption.MAPIUtils');
rdUtils.DeliverNow;
olNameSpace.Logoff;
varclear (rdUtils);
varclear (rdSafeItem);
varclear (olItem);
varclear (olNameSpace);
varclear (olApp);
end;
After the email is sent, I get an access violation message at address A70D6D13 (this address seems to be constant). If I step through the entire procedure with F8, after the 'end' statement, the CPU window gets displayed at address A70D6D13, showing all the memory as ????.
I'm using Delphi 7, Outlook 2003, Redemption 4.8.0.1184 What is missing from this code?
EDIT: I've found a few other code snippets to send mail via Outlook/Redemption. Here is one such snippet which uses the OutlookApplication server.
begin
outlookapplication1.Connect;
NmSpace:= outlookapplication1.GetNamespace('MAPI');
NmSpace.Logon('', '', False, False);
oItem:= outlookapplication1.CreateItem(olMailItem);
sItem:= CreateOleObject('Redemption.SafeMailItem');
oItem.Subject:= 'my subject';
oItem.save;
sItem.Item:= oItem;
sItem.Recipients.Add('test@test.com');
sItem.Attachments.Add('C:\windows\win.ini');
sItem.save;
SItem.send;
outlookapplication1.Disconnect;
end;
This too gives the same error. What is magical about the address of the AV? It must be a clue to the solution.
TIA,
No'am