Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple email of a form

Posted on 1999-07-13
30
Medium Priority
?
172 Views
Last Modified: 2010-04-06
I am developing a program using Delphi 4 Professional.  I would like a user to be able to email me a registration form  by filling out the fields in a form and pressing a "register via email" button, which would email me a file containing data from the form.

I have essentially no experience with internet programming.  Is there a (relatively) simple way of doing this and if so, what is it?
0
Comment
Question by:prstein
[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
  • 7
  • 6
  • 5
  • +6
30 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 1388277
On http://www.rtfm.be/fpiette/smtpcliuk.htm you can download a component that includes a full demo. I think it's a good idea to start with this one.

Regards,

Epsylon.
0
 
LVL 15

Expert Comment

by:simonet
ID: 1388278
prstein,

Go to  http://www.bhnet.com.br/~simonet/howtoprojs.htm and download the sample application entitled "How to send e-mail and faxes from your Delphi/C++ Builder application"

It will give you a complete understanding of how to send e-mai and faxes from your Delphi application. No additional components are required, and full source code is included.

Yours,

Alex
Athena's Place: http://www.bhnet.com.br/~simonet

0
 
LVL 1

Author Comment

by:prstein
ID: 1388279
Thank you both.  I've downloaded the referenced files but have not gotten either of them to work.

I guess what I'm looking for is a way to modify the following line of code I found (triggered by pressing a button):

ShellExecute(0, Nil, 'mailto:me@mydomain.com?subject=Registration', Nil, Nil, SW_NORMAL);

such that an attachment, say "register.txt" is included.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:prstein
ID: 1388280
The referenced file would not work properly once it was loaded into Delphi.  I tried several times.  It also looked somewhat more complicated than what I am looking for (see my comment).
0
 
LVL 15

Expert Comment

by:simonet
ID: 1388281
>such that an attachment, say "register.txt" is included.

impossible to do attachments using ShellExecute. No way. No in this life. Impossible.

the only possible ways of sending attachments is by calling a lower-level interface, such as S-MAPI (the solution I proposed), SMTP (as Epsylon suggested), or similar stuff. You cannot sending attachments without going through one of these interfaces, undestand?

>what I am looking for (see my comment).

The options presented by Epsylon and I were very good. What you were expecting to hear (ShellExecute) is somethig impossible to achieve.

Alex
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1388282
Prstein.

Please post your email address and I'll give you some sample code which will do exactly what you want.

You can not use ShellExecute to send files via email.  You must use either SMTP or MAPI.  MAPI is becoming harder to support as Microsoft have removed MAPI support in Outlook Express 5 (which means eventually all mail clients will go that way too), therefore SMTP is definately the way to go.

Now, the only problem with using SMTP is that we have to know what the users' mail server address is (like mail.myserver.com).  We can find this from the registry, but it should be verified with the user before attempting the post.

Best wishes,


Stuart.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1388283
Alex:  Its done it again :)  I didnt mean to duplicate your comments, but when I entered this question, the last comments where from prstein.  Sorry mate.

Stu.
0
 
LVL 15

Expert Comment

by:simonet
ID: 1388284
No problem! Actually it's good to reinforce that what the user wants to do the way he wants it to be is impossible.

Alex
0
 
LVL 17

Expert Comment

by:inthe
ID: 1388285
hi,
as everyone has said you cant send file attachments using shellexecute but you can send the message body if its in a memo for example you can do this:

procedure TForm1.Button1Click(Sender: TObject);
Var
Buffer : String;
recip,subj,mess : String;
begin
recip:= Edit1.text;   {message recipients email address}
subj:=Edit2.Text;     {message subject}
Mess:= Memo1.Text;    {message body / registration info}
Buffer:='mailto:'+recip+'?subject='+subj+'&body='+mess;
ShellExecute(Application.Handle,'open',PChar(Buffer),nil,nil,SW_Normal);  
Edit1.Clear;        
Edit2.Clear;     {and clean up}
Memo1.Clear;      
end;

This will take the params (recipient,subject,and message)and send to the recipient if thats any help at all..
Regards Barry
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1388286
Im sure that three people should be able to convince him :)

prstein.  Just as a further comment, I have been writing MAPI, SMTP and MAPI applications for around 3 years now, and (not sounding like Im spanking my monkey too much), I think I know quite a bit about this topic.  There is definately no _DOCUMENTED_ method of posting a file from the command line (which is effectively what ShellExecute is).

Regards,

Stuart.


0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1388287
Oh good on ya Barry!  Just come in and shoot us all down in flames :)

Well done!  I didn't even think of that.

prstein:  There you go.  That should do what you want - but it will NOT send files which I dont think you will need to do after Barry's suggestion.

Stu.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1388288
:-)
0
 

Expert Comment

by:fosco
ID: 1388289
good job inthe.. little round about way of doing things.. but thats quite nice... the only thing I don't like about all your options.. is that it launches their default mail client.. why not use NMSmtp which comes with D4.. or fpiettes... fpiette has a component called MX which will FIND their mail server...

fosco

0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1388290
Thats what everyone else has been trying to say, Fosco, but prstein didn't want to do it that way (hence the rejection of Alex's answer and the fact Epsylons comments went unheard).  I also offered to send an example using SMTP but I haven't heard anything back yet.

Barry's suggestion solves the problem perfectly if this is the way prstein wants to proceed.  It does have the draw-back of launching the default email client, and that is unavoidable as it is the associated application for mailto:

Cheers,

Stuart.
0
 

Expert Comment

by:AndyJohn
ID: 1388291
prstein,

let me have your email address and I will send you a component to do the job.
0
 
LVL 15

Expert Comment

by:simonet
ID: 1388292
AndyJohn, what kinda answer is that? Are you trying to lock the question for yourself? I advise you that what you're doing is quite unethical here.

prstein, REJECT AndyJohn's answer, since it's not an answer.

Alex
0
 

Expert Comment

by:AndyJohn
ID: 1388293
simonet,

chill your boots.......if prstein wnats the component he can have it.  If it does the job then it is an answer.  The only reason I offered to mail it to him is because I dont remember where I got it off the web.

I dont understand where you get "unethical" from.

if you want points so bad that you wish to shout at me then go ahead, I dont mind.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1388294
AndyJohn,

You have not posted an ANSWER.  You have posted a possibility.  An answer is a definate solution to a problem.  Now we can not see that solution as it is in the form of an emailed component, therefore it should be posted as a comment.

No one else has posted an answer like that even though numerous offers have been made to prstein with components.

As Alex said, it is unethical to post an answer without a complete solution.

Stuart.


0
 

Expert Comment

by:AndyJohn
ID: 1388295
Ok, I understand where you are coming from now.  I am quite happy with that.  I hope you accept that there was no ill intention.  

However I do urge prstein to get the component as I know it will do the job and hence ultimatly provide a solution.

In the mean time if I can find out where I got it from I'll post the URL as a proposed answer so you can all get it.  BTW - it is freeware so there is no problem there.

toodle pip.
0
 

Expert Comment

by:AndyJohn
ID: 1388296
Ok, I understand where you are coming from now.  I am quite happy with that.  I hope you accept that there was no ill intention.  

However I do urge prstein to get the component as I know it will do the job and hence ultimatly provide a solution.

In the mean time if I can find out where I got it from I'll post the URL as a proposed answer so you can all get it.  BTW - it is freeware so there is no problem there.

toodle pip.
0
 

Expert Comment

by:AndyJohn
ID: 1388297
Hahaha, look what I found.

Give it a go it is very good.

http://www.econos.de/software/borland
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1388298
AndyJohn,

Thats cool.  At the moment there is a bit of tension around with the way things are being done here, and it is infuriating quite a few people.  We are all trying to get some sort of a standard happening here.

We appreciate help from everyone, it's just annoying when someone has spent a day or more helping someone with a problem only to have someone drop in out of nowhere and propose an answer which could have already been done ages ago.

Most of us a very honest would not take the points of another expert for a question they answered.  Therefore you are safe posting a good answer as a comment.  Also, in future, do what you did then and post the URL for any components so that everyone can download the suggestion and evalutate the suggestion as well.  Thats what this whole system is about - exchange of information, and by keeping the answer hidden from everyone else (because the answer has been emailed) means the information exchange has stopped.

Thanks anyway for the URL. I'll definately check it out!


Stu.
0
 
LVL 1

Author Comment

by:prstein
ID: 1388299
Everyone:
Wow. Thanks. Your response is great!

Barry:
Brilliant! That works perfectly.  Please post answer for points.

AndyJohn:
I grabbed the component, but it won't work on my machine because I have no MAPI email thingy.

Stuart Johnson:
I like AndyJohn's answer because it is so simple and requires so little change to my existing code.  I wouldn't mind if still you sent the code to me at prstein@gyral.com (Note-this is my public/spam address.  If the file takes more than about 1 meg it will be rejected, so you could also drop me a quick private note and I'll send you a different address.)  If your's is a better solution than AndyJohn's, I'll gladly repost the question to give you the points, too.

Thanks again,

Paul
0
 
LVL 1

Author Comment

by:prstein
ID: 1388300
Whoops;
message to Stuart Johnson should have read
I like Barry's answer because it is so simple and requires so little change to my existing code.  I wouldn't mind if still you sent the code to me at prstein@gyral.com (Note-this is my public/spam address.  If the file takes more than about 1 meg it will be rejected, so you could also drop me a quick private note and I'll send you a different address.)  If your's is a better solution than Barry's, I'll gladly repost the question to give you the points, too.

Sorry for the typo
0
 
LVL 1

Expert Comment

by:pede
ID: 1388301
I just tried Barry's suggestion. I did a pure cut'n'paste, but it didn't work for me! Outlook opened a send-dialog, with everything in the 'To' field. Dunno why.

/pede

0
 
LVL 1

Author Comment

by:prstein
ID: 1388302
pede:

What I actually did was this (pasted from my code)

procedure TfrmRegistrationForm.BitBtn1Click(Sender: TObject);
Var
  Buffer : String;
  recip,subj,mess : String;
begin
  Mess:= edtFirstName.Text + ' ' + edtLastName.text; {And so on for message body / registration info}
  Buffer:='mailto:prstein@gyral.com?subject=Software Registration&body='+mess;
  ShellExecute(0, Nil,PChar(Buffer),nil,nil,SW_Normal);
end;

And it works perfectly.

Paul
0
 
LVL 1

Expert Comment

by:pede
ID: 1388303
Hi

Buffer:='mailto:pe@des.dk?subject=Test&body=Body';
ShellExecute(Application.Handle,'open',PChar(Buffer),nil,nil,SW_Normal);

These two lines does not work for me. Still, I get a dialog from Outlook, where the whole string is in the 'To' field. If I try to send it, I get an error (the adress is illegal). I suppose it should be sent, without any dialog showing? Maybe it's a configuration thing? I use NT and Outlook97.

It could be me doing something wrong, but if I was you, I would test it on a similar machine... ;)


/Pede

0
 
LVL 1

Author Comment

by:prstein
ID: 1388304
Pede:

Try changing the line
ShellExecute(Application.Handle,'open',PChar(Buffer),nil,nil,SW_Normal);

to
ShellExecute(0, Nil,PChar(Buffer),nil,nil,SW_Normal);

I don't actually know what I'm doing (I'm not by any stretch an "Expert"), but give that a try.

Paul
0
 

Expert Comment

by:msysm
ID: 1388305
Outlook/Exchange (i.e. Microsoft) ignore the parameters after a ? in such emails.  I know Netscape email client, if the default on your system, works okay.  Try using <A href="mailto:null@msysm.co.uk?subject=test">click here</A> on a web page.  It will fail with the symptoms you describe in IE but work correctly in Netscape.

Therefore perhaps the problem Pede is experiencing is Microsoft's fault!  Is using ? to delimit parameters a recognised standard?

P.S. sorry that this is getting off topic
0
 
LVL 17

Accepted Solution

by:
inthe earned 1200 total points
ID: 1388306
hi Paul,
glad you like my "simple way" (im a simple kinda guy *-)

procedure TForm1.Button1Click(Sender: TObject);
Var
Buffer : String;
recip,subj,mess : String;
begin
recip:= Edit1.text;   {message recipients email address}
subj:=Edit2.Text;     {message subject}
Mess:= Memo1.Text;    {message body / registration info}
Buffer:='mailto:'+recip+'?subject='+subj+'&body='+mess;
ShellExecute(Application.Handle,'open',PChar(Buffer),nil,nil,SW_Normal);  
Edit1.Clear;          
Edit2.Clear;     {and clean up}
Memo1.Clear;
end;

that worked for me on win98 with outlook express 5 and winnt(sp5) with outlook98 so dont know what pede's problem is ?

anyway good luck and hope everyone registers your proggie and you make a million
Regards Barry
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

715 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