Xbase++ SMTP Class

 Top Next

Created by Softsupply Informatica

Rua Alagoas, 48

01242-000

São Paulo, SP

Brazil

Tel (5511) 3159-1997

Fax (5511) 3255-5224

Email : softsupply@terra.com.br

Contact : Edgar Borger


Intro

 Top Previous Next

This class was created to help Xbase++ users in sending emails thru the internet using Winsock resources.

This is a very simple class with very little effort in terms of programming, of course implementing it will require code changes, but the benefits are worth it.

An example of a simple program would be :

  PROCEDURE MAIN

oSmtp := xbpSMTP():New() | // Creates the SMTP object
oSmtp:Create( cHost, cUser, cPass ) | // Tell the class then SMTP server, username and password.
oSmtp:SendMail( cTo, cFrom, cSubject, cMsg ) | // Send the message
oSmtp:Destroy() | // End the process

  Return


New

• New( cKey ) => Initializes the class object.

cKey (character) :  Key to remove the DEMO restriction.


Create

New

• Create( cHost, [cUser], [cPassword], [nPort] ) => Conect to the host server.

§ cHost (character)

: Name or IP number of the STMP host server.
§ cUser (character)

: User name at the STMP host server.
§ cPassword (character)

: Password of the email account.
§ nPort (numeric)

: SMTP Port number. (default is 25)


SendMail

New

• SendMail( cTo, cFrom, cSubject, cMsg, [cAttach], [cCopy], [cBCopy] ) => Sends the email.

§ cTo (character)

:

Email recipient.
§ cFrom (character)

:

Sender's email.
§ cSubject (character)

:

Email subject.
§ cMsg (character)

:

Email message body.
§ cAttach (character)

:

Email attachment, full path filename.
§ cCopy (character)

:

Email copy recipient, it can be a comma separated list, or and array of recipients.
§ cBCopy (character)

:

Email Blind copy recipient, may be a comma separated list or an array of email address.

Examples :

a) oSMTP:SendMail( "anyname@email.com", ;

"myemail@host.com", ;

"message subject", ;

"message text", , ;

"mail2@anymail.com, mail3@anymail.com, mail4@anymail.com")

This will send the email to anyname@mail.com with blind copies to mail2@anymail.com, mail3@anymail.com and mail4@anymail.com

b) aBcc := { "mail2@anymail.com", ;

            "mail3@anymail.com", ;

            "mail4@anymail.com" }

  oSMTP:SendMail( "anyname@email.com", ;

"myemail@host.com", ;

"message subject", ;

"message text", , ;

aBcc )

This will do the same thing.


Log

• Log( lLogEvents, cLogFile ) => Start or stops logging smtp messages.

§ lLogEvents (logical)

:

True will open the log file, and start logging SMTP events, and False will stop logging and close the log file.
§ cLogFile (character)

:

Name of an optional Log file to register all data flow.


Destroy

New

• Destroy( ) => Releases all object resources and closes the log file


Class Variables

cHost | name or IP address of the SMTP server.
cUser | user (account) name at the SMTP server.
cPass | user (account) password at the SMTP server.
cRecipient | main recipient for the message.
cSender | email sender.
cSubject | subject line for the message.
cBody | message body (text).
cAttach | full path filename of the file to be attached to the message.
cCc | comma separated list or array of emails to receive a message copy.
cBcc | comma separated list or array of emails to receive a blind message copy.
cLog | log file name.
lDebug | True or False. If True, will display flow on screen.


Demo

 Top Previous

This is a sample program that is included in this package, by analyzing it, you will be able to see how simple its is, and at the same time how powerful this new class is.

#pragma library( "XbpSMTP.Lib" )

PROCEDURE MAIN

  LOCAL cTo, cFrom, cSubject, cMsg

  oSmtp     :=  xbpSMTP():New()

  oSmtp:Create( "smtp.host.com", "hostusername", "hostpassword" )

  cMsg      :=  "This is a test message sent with the XbpSMTP class"

  cSubject  :=  "SMTP Class test message"

  cTo       :=  "test@anymail.com"

  cFrom     :=  "myemail@host.com"

  oSmtp:SendMail( cTo, cFrom, cSubject, cMsg )

  oSmtp:Destroy()

return