Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calling default mail program

Posted on 1998-10-26
14
Medium Priority
?
147 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 400 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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