Board index » delphi » Sending mail with Outlook 2007

Sending mail with Outlook 2007


2007-05-16 06:37:46 AM
delphi195
How do I send e-mail using Outlook 2007? I am using D7, with the following
code works well with Outlook 2003 and prior versions:
procedure TForm1.Button1Click(Sender: TObject);
var
MSOutlook, MSItem: OLEVariant;
begin
MSOutlook := CreateOleObject( 'Outlook.Application' ); // in ComObj.pas
MSItem := MSOutlook.CreateItem(0);
MSItem.To := 'XXXX@XXXXX.COM';
MSItem.Subject := 'hello';
MSItem.Body := 'Some message';
MSItem.Send;
end;
When I try this method with Outlook 2007, nothing happens. Any ideas what I
might be doing wrong?
Byron Upchurch
 
 

Re:Sending mail with Outlook 2007

borland.public.delphi.oleautomation is a much better location for this
question.
--
Christian Wilkerson
CAUTION - Home made country music
@ www.myspace.com/christianwilkersonmusic
"Byron Upchurch" <XXXX@XXXXX.COM>writes
Quote
How do I send e-mail using Outlook 2007? I am using D7, with the
following code works well with Outlook 2003 and prior versions:

procedure TForm1.Button1Click(Sender: TObject);
var
MSOutlook, MSItem: OLEVariant;
begin
MSOutlook := CreateOleObject( 'Outlook.Application' ); // in ComObj.pas
MSItem := MSOutlook.CreateItem(0);
MSItem.To := 'XXXX@XXXXX.COM';
MSItem.Subject := 'hello';
MSItem.Body := 'Some message';
MSItem.Send;
end;

When I try this method with Outlook 2007, nothing happens. Any ideas what
I might be doing wrong?

Byron Upchurch

 

Re:Sending mail with Outlook 2007

How do I send e-mail using Outlook 2007? I am using D7, with the following
code, and it works well with Outlook 2003 and prior versions:
procedure TForm1.Button1Click(Sender: TObject);
var
MSOutlook, MSItem: OLEVariant;
begin
MSOutlook := CreateOleObject( 'Outlook.Application' ); // in ComObj.pas
MSItem := MSOutlook.CreateItem(0);
MSItem.To := 'XXXX@XXXXX.COM';
MSItem.Subject := 'hello';
MSItem.Body := 'Some message';
MSItem.Send;
end;
When I try this method with Outlook 2007, nothing happens. Any ideas what I
might be doing wrong?
Byron Upchurch
 

Re:Sending mail with Outlook 2007

Does the message get sent when you open Outlook?
Add the following code after creating an instance of the Outlook.Application
object.
NS := MSOutlook.GgetNamespace('MAPI')
NS.Logon;
Dmitry Streblechenko (MVP)
www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Byron Upchurch" <XXXX@XXXXX.COM>writes
Quote
How do I send e-mail using Outlook 2007? I am using D7, with the
following
code, and it works well with Outlook 2003 and prior versions:

procedure TForm1.Button1Click(Sender: TObject);
var
MSOutlook, MSItem: OLEVariant;
begin
MSOutlook := CreateOleObject( 'Outlook.Application' ); // in ComObj.pas
MSItem := MSOutlook.CreateItem(0);
MSItem.To := 'XXXX@XXXXX.COM';
MSItem.Subject := 'hello';
MSItem.Body := 'Some message';
MSItem.Send;
end;

When I try this method with Outlook 2007, nothing happens. Any ideas what
I
might be doing wrong?

Byron Upchurch



 

Re:Sending mail with Outlook 2007

Hello Dmitry,
Thank you very much. This worked!
Byron
"Dmitry Streblechenko" <XXXX@XXXXX.COM>writes
Quote
Does the message get sent when you open Outlook?
Add the following code after creating an instance of the
Outlook.Application object.

NS := MSOutlook.GgetNamespace('MAPI')
NS.Logon;

Dmitry Streblechenko (MVP)
www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Byron Upchurch" <XXXX@XXXXX.COM>writes
news:464b27a0$XXXX@XXXXX.COM...
>How do I send e-mail using Outlook 2007? I am using D7, with the
>following
>code, and it works well with Outlook 2003 and prior versions:
>
>procedure TForm1.Button1Click(Sender: TObject);
>var
>MSOutlook, MSItem: OLEVariant;
>begin
>MSOutlook := CreateOleObject( 'Outlook.Application' ); // in ComObj.pas
>MSItem := MSOutlook.CreateItem(0);
>MSItem.To := 'XXXX@XXXXX.COM';
>MSItem.Subject := 'hello';
>MSItem.Body := 'Some message';
>MSItem.Send;
>end;
>
>When I try this method with Outlook 2007, nothing happens. Any ideas
>what I
>might be doing wrong?
>
>Byron Upchurch
>
>
>