Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple SMTP email 1

Status
Not open for further replies.
Joined
Sep 17, 2001
Messages
673
Location
US
Is there a simple way to email in FoxPro without having to use some shareware program? All I want to do is connect to an SMTP server and send an email. I would also like to use attachments. I don't want to use the default mail client like Outlook or Notes. I want to use SMTP (simple mail) So really I want to use the functionality already in FoxPro to email not Rick Strahl's addon's or Marshall soft's shareware addon's. If anyone knows of a small third party ocx etc that is freeware with no baggage I would be interested. Thanks!
 
robsutonjr

Have you looked at faq184-1768 and faq184-1769? Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
I like the first faq but I don't see where the smtp server and port are set.
 
You could study up on the SMTP protocol and use the WinSock functions (otherwise, you'll have to use SOME client software that understands SMTP):

int connect (
SOCKET s,
const struct sockaddr *name,
int namelen );

int send (
SOCKET s,
const char *buf,
int len,
int flags );

and

int recv (
SOCKET s,
char *buf,
int len,
int flags );

Here's more info on the WinSock functions:
 
PUT THE FOLLOWING IN A PROGRAM CALLED SENDMAIL.PRG
(FOLLOW THE INSTRUCTIONS BELOW TO DOWNLOAD THE SMTP.OCX and REGISTER IT, SIMPLEST, FREE WAY.



PARAMETERS lcTo,lcSubject,lcBody,lcFile

** TO USE THIS PROGRAM DO THE FOLLOWING:
** COPY THE SMTP.OCX file to your system32 directory
** (The following is the link to the original copy)
** ** go to a cmd prompt cd to winnt\system32 then type regsvr32 smtp.ocx
** if you register successfully you should be able to use this program


** CUSTOMIZE TO FIT YOUR NEEDS
oSmtp = CREATEOBJECT("SMTPControl.SMTP")

oSmtp.Server="192.168.1.1"
oSmtp.Port=25

oSmtp.MailFrom="rob@yoohoo.com"
oSmtp.SendTo=lcTo

oSmtp.MessageSubject=lcSubject
oSmtp.MessageText=lcBody

*oSmtp.CC=""
*oSmtp.BCC=""

** Attachments

oSmtp.Attachments.Add(lcFile)
*(also .count .item .remove ._NewEnum)


** Other/Misc
*oSmtp.Password=""
*oSmtp.Charset=""
*oSmtp.MailDate=""
*oSmtp.MessageHTML=""
*oSmtp.Status
*oSmtp.UserName=""

** CONNECTS TO SERVER SEND MAIL THEN DISCONNECTS
oSmtp.SendEmail
 
Dear robsutonjr

I reckon Mike Gagnon's solution does it all for you ...

Have you even looked at his suggestions FAQ184-1768 and FAQ184-1769?

I reckon that they are elegant solutions...

JF
 
Well thanks but I was not looking for elegant, I asked for simplicity. I did look at the 2 faq's and found the simple answer by searching the web for an smtp.ocx file. (I also don't want use outlook or rely on a default mail cleint on the workstation). The following only requires a FREE & SIMPLE smtp.ocx be registered and the following code:

oSmtp = CREATEOBJECT("SMTPControl.SMTP")
oSmtp.SERVER="192.168.1.1"
oSmtp.Port=25
oSmtp.MailFrom="joesomeone@somewhere.net"
oSmtp.SendTo="suesomeone@somewhere.net"
oSmtp.MessageSubject="Spreadsheet"
oSmtp.MessageText="Here is your spreadsheet."
oSmtp.Attachments.Add("c:\Spreadsheet.xls")
oSmtp.SendEmail

I appreciate everyones input and have found this forum to be an invaluable resource. Thanks comrades!
 
Hi robsutonjr,

I tried the smtp.ocx activeX control with the code you provided in an email app, and it really works great. Thanks,
Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
robsutonjr,

this really great! but how about checking/recieving email from the server?
 
Sorry for the slow reply. SMTP is a simple mail transport protocol (not for checking email). You might try checking out POP3 classes. West Wind and Marshall Soft have a POP3 classes. Do a search on google.com for "pop3.ocx" I haven't had a chance to try them however and did not find a free version.
 
Now, part of the original request was an OCX that was freeware, "With no baggage". All of the free SMTP.OCX files I've seen require the VB runtime files... which most people have, but definitely some don't.

The Ostrosoft SMTP.OCX above DOES require the VB6 runtime "(MSVBVM60.dll, etc.)" as noted at under the FAQ "When registering control I'm getting message 'LoadLibrary("smtp.ocx") Failed'"
 
I loaded this the smtp.ocx without a need to load the VB6 runtime on Windows 2000 machines. I guess this means that if you have a newer OS no worries. I want to put more emphasis on free and simple. You can't really get away with just having one ocx and never worry on any OS. However I did find this ocx very simple compared to West Wind and others. Not that West Wind is bad, just wanted a simple, free, and minimal baggage addon. Works for me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top