SendEmail class library for Visual FoxPro 8.0
September 2004, News2News
The library implements sending email messages through SMTP and Webmail (Hotmail and MSN) servers. The attached source code is preliminary version distributed for testing purposes only.
Minimal system requirements
Windows XP/2000
Visual FoxPro 8.0
Implemented functionality
Email headers, multi-part messages and file attachments; multiple recipients, base64 and quoted-printable encoding...more...
Not implemented functionality
SMTP authentication...more...
Classes included
The library contains two main classes:
- MSG - email message
- MAILGATE - connection to email server
Other classes:
- email address
- email header
- tcp socket
- email message part (alternative body or file attachment)
Sending email message, steps:
- create message object (MSG)
- fill message object with data:
- subject
- sender
- recipients
- headers
- body
- attachments
- create mailgate object (MAILGATE_DUMB, MAILGATE_SMTP, MAILGATE_HOTMAIL)
- establish connection with a mail server in either way:
- pass connection parameter(s) to CREATEOBJECT
- run connect method directly
- pass the message object to sendmessage method of the mailgate
Mailgates
The mailgate implements connection to mail server -- SMTP or Hotmail/MSN. All three mailgates inherit from the MAILGATE class. Instantiating MAILGATE directly is not required.
MAILGATE_DUMB
This mailgate is for testing purposes only and is not connected to any server. After running its sendmessage method retrieve would-be sent message from its msgbuffer property.
MAILGATE_SMTP
To use this mailgate pass valid SMTP server name either to CREATEOBJECT or to connect method of MAILGATE_SMTP object. Very often SMTP servers do not require authorization, so a server name is enough if you connect from proper ip address.
MAILGATE_HOTMAIL
To use this mailgate pass valid Hotmail or MSN address and password either to CREATEOBJECT or to connect method of MAILGATE_HOTMAIL object.
Program files
- sendemail.vct
- sendemail.vcx
- hotmail.h
- smtp.h
- winsock.h
Code samples
test00.prg -- creates three main objects: message, smtp mailgate and hotmail mailgate. Server names and passwords are not required.
test01.prg -- creates and populates a message object then opens its preview using dumb mailgate. Server names and passwords are not required, the message is not sent to anywhere.
test02.prg -- sends plain-text message with attached file using SMTP server. Provide valid content for smtp server, sender, recipient(s), subject, body, file(s) to be attached. Properly configured code will actually send the message.
test03.prg -- sends plain-text message with attached file using Hotmail or MSN server. Provide valid Hotmail/MSN address and password, sender, recipient(s), subject, body, file(s) to be attached. Properly configured code will actually send the message.
Contact info:
Anatoliy Mogylevets