BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

'A program is trying to access e-mail...' - How do I get rid

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Thu Aug 24, 2006 8:12 am    Post subject: 'A program is trying to access e-mail...' - How do I get rid Reply with quote



Hi,

I am trying to send an email using outlook (through Delphi 2006) and
when the email is generated and displayed, I get a message from Outlook
which says 'A program is trying to access e-mail addresses....'. What
is the best way to stop this? I have done a search of some user groups
and the 2 solutions mentioned are a plugin called Redemption or a
program called Express ClickYes. Is there any other way to get around
this? The code I am running is below. If anyone can help I would be
very grateful.

Richard

function TOutlookEmail.SendMail: TMailStatus;
const
olMailItem = 0;
olCC = 2;
olBCC = 3;
ClassString = 'Outlook.Application';
var
Outlook: OleVariant;
vMailItem: OleVariant;
myRecipient: OleVariant;
i: Integer;
begin
Result.ErrorMsg := '';
Result.ErrorType := etNoProblem;


if (Recipient.Count = 0) and (ShowDialog = false) then begin
Result.ErrorType := etNoRecipent;
Result.ErrorMsg := 'You must specifiy at least one recipent';
Exit;
end;

try
Outlook := CreateOleObject(ClassString);
except
Result.ErrorType := etNoOutlook;
Result.ErrorMsg := 'Failed to create outlook instance';
Exit;
end;
vMailItem := Outlook.CreateItem(olMailItem);
for i := 0 to Recipient.Count - 1 do begin
vMailItem.Recipients.Add(Recipient[i]);
end;
for i := 0 to CC.Count - 1 do begin
myRecipient := vMailItem.Recipients.Add(CC[i]);
myRecipient.type := olCC;
myRecipient := Unassigned;
end;
for i := 0 to BCC.Count - 1 do begin
myRecipient := vMailItem.Recipients.Add(BCC[i]);
myRecipient.type := olBCC;
myRecipient := Unassigned;
end;
vMailItem.Subject := Subject;

for i := 0 to Attachment.Count - 1 do
vMailItem.Attachments.Add(Attachment[i]);

try
vMailItem.Display;
except
// incorrect function error shown here for some reason.
// looks like its some sort of Outlook error. make sure that
// user has Tools/Options/Mail Format - Use Microsoft Word 2003 to
// edit e-mail messages otherwise error when assigning body
end;

Result.ErrorType := etDisplayed;

if BodyType = olHTMLText then
vMailItem.HTMLBody := RepStr(FHTMLBody.Text,#13#10,'<br>') +
vMailItem.HTMLBody
else
vMailItem.Body := FBody.Text + vMailItem.Body;


if ShowDialog = false then begin
vMailItem.Send;
Result.ErrorType := etSent;
end;

vMailItem := Unassigned;
Outlook := Unassigned;
end;
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.