Solved

Calling default mail program

Posted on 1998-10-26
14
143 Views
Last Modified: 2010-04-06
I need to call the default mail program from my application. At the same time, I'd like to submit text to the Subject property and Message property of the new mail.

This is for a 'Recommend this program to your best friend'-feature. The user clicks a Recommend button, and a new mail is created with the subject 'Recommended software: xyz' and the text 'The software xyz is freeware. You can download it from: www.abc.com'.
The user only has to write the recipients mail address and press the send button of his/her default mail program.

Any help is appreciated!
Thanks in advance.
0
Comment
Question by:friberg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
14 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344414
Hi friberg,

I latest learned about this one :


ShellExecute(0, 'open', 'mailto:xxx@xx.xx', 'subject', nil, SW_NORMAL);

But I don't know if a message body can directly be added.

I used to use MAPI, which is able to add a message body :

read about it all and use this freeware component at

http://torry.rimini.com/vcl/internet/temail2.zip

Regards, Zif.
0
 

Author Comment

by:friberg
ID: 1344415
Thanks ZifNab, but I need to call the standard mail program, not MAPI.

Maybe someone nows how to add a message as well with ShellExecute?


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344416
friberg,

MAPI is for talking to mapi compliant e-mail programs, like Outlook and Eudora. You send your e-mail with MAPI messages to the email program on the pc. So, with MAPI you normally call the default e-mail program. Look at the docs of the component I referred to.

you can even add your attachments directly!

Zif.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1344417
Hi friberg,

I did some research and found out how to add the body message :

procedure TForm1.Button1Click(Sender: TObject);
var
  TempUrl : string;
begin
  TempUrl:='mailto:tom.deprez@village.uunet.be?subject=Your subject&body=test body';

ShellExecute(Application.Handle,'open',PChar(TempURL),nil,nil,SW_NORMAL);
end;

ps. don't know if it will work for every e-mail client!
pps. I know it does for outlook, and netscape.
ppps. As I said, with MAPI you can already attacht the file and all the rest. And even send it! ShellExecute just opens a new email for you and fills in some stuff.
0
 

Author Comment

by:friberg
ID: 1344418
ZifNab,

Although I use Outlook Express, the component gave me the message 'MAPI services are not available on this system'.


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344419
Forgot something : if you want to use shellexecute, you need to add 'shellapi' to the uses clause.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344420
Hi friberg, I'm sorry to say that I made a mistake about MAPI. MAPI compliant systems are : Eudora, MS Exchange and other which I don't know of. Outlook Express isn't one of them. Sorry. Zif.
0
 

Author Comment

by:friberg
ID: 1344421
I need a solution that will work with IE4 and Netscape users as well (without having extra mail readers installed).
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344422
As I said : ShellExecute works for IE4 (=Outlook) and NetScape,

Try it out!

 Zif.
0
 

Author Comment

by:friberg
ID: 1344423
I have, but it won't let me add any text, only recipient and subject. Since it's a 'tell your friend about this program' feature, I don't know the recipient, only a subject, eg 'my program - recommended'. I want to put a link to my program in the text field, not in the subject field.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344424
Hi friberg,

I used this string :

'mailto:tom.deprez@village.uunet.be?subject=Your subject&body=test body';

in this

procedure TForm1.Button1Click(Sender: TObject);
var
  TempUrl : string;
begin
  TempUrl:='mailto:tom.deprez@village.uunet.be?subject=Your subject&body=test body';


ShellExecute(Application.Handle,'open',PChar(TempURL),nil,nil,SW_NORMAL);
end;

with D3.02 and IE4 and Outlook Express

And it works perfectly :

It opens a mail and adds these values :

To : Tom.Deprez@village.uunet.be
Subject : Your subject
Body : your body

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344425
Hi friberg,

I used this string :

'mailto:tom.deprez@village.uunet.be?subject=Your subject&body=test body';

in this

procedure TForm1.Button1Click(Sender: TObject);
var
  TempUrl : string;
begin
  TempUrl:='mailto:tom.deprez@village.uunet.be?subject=Your subject&body=test body';


ShellExecute(Application.Handle,'open',PChar(TempURL),nil,nil,SW_NORMAL);
end;

with D3.02 and IE4 and Outlook Express

And it works perfectly :

It opens a mail and adds these values :

To : Tom.Deprez@village.uunet.be
Subject : Your subject
Body : test body

Regards, Zif.
0
 

Author Comment

by:friberg
ID: 1344426
Thanks, it works perfectly!
Please send it as an answer.
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 100 total points
ID: 1344427
Hi friberg,

Are you sure, because you said it didn't work?

To answer :

I used this string :

'mailto:tom.deprez@village.uunet.be?subject=Your subject&body=test body';

in this

procedure TForm1.Button1Click(Sender: TObject);
var
  TempUrl : string;
begin
  TempUrl:='mailto:tom.deprez@village.uunet.be?subject=Your subject&body=test body';


ShellExecute(Application.Handle,'open',PChar(TempURL),nil,nil,SW_NORMAL);
end;

with D3.02 and IE4 and Outlook Express

And it works perfectly :

It opens a mail and adds these values :

To : Tom.Deprez@village.uunet.be
Subject : Your subject
Body : test body

Regards, Zif.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question