SamLogic Internet Components - Home
ActiveX: SLSMTP      (Filename: SLSMTP.OCX)


SLSMTP is an ActiveX component you can use to send e-mails via an SMTP server. You can send HTML messages and plain text messages with this control. The HTML messages can have pictures and sound embedded in the message. The control makes the appropriate Base64-conversion of the objects so e-mail clients can see the pictures and hear the sound when they open the message. You can also add attachments to an e-mail. SLSMTP uses the SMTP protocol when communicating with the e-mail server. Authentication is supported.

Some e-mail servers require a POP3 login before the SMTP services at the e-mail server can be used. If the e-mail server you want to connect to require it, you can use the SLPOP3 component to achieve this before you login to the SMTP server.
 
 
Properties
 
Name Type Description
Attachment String Specifies one or more files that should be attached to the e-mail message. If you attach more than one file, the file paths must be separated with a "|" character.
 
BCC String Specifies one or more e-mail addresses that should receive a blind carbon copy of the email message. If you use more than one e-mail address you should separate the addresses with a comma (,).
 
Body String Specifies a plain text message body. This property is only used if DocumentType is set to 0.
 
BodyHTML String Specifies an HTML message body. This property is only used if DocumentType is set to 1.
 
BytesSent Long Contains the number of bytes sent. Before reading this property the SendCompleted event must have been fired.
.
Charset String Specifies the character set used in the message. The default value for this property is "iso-8859-1". Here you find a list of some available character sets.
 
CC String Specifies one or more recipients that should receive a copy of the e-mail message. If you use more than one e-mail address you should separate the addresses with a comma (,).
 
DocumentFolder String Specifies the folder where an HTML document is located. You only need to specify this property if the document/message contains pictures or sound and the paths might be relative. The relative paths will be converted to correct absolute paths using this property as the start folder.
.
DocumentType Integer Specifies the type of document to send. 0 = plain text ("text/plain") and 1 = HTML ("text/html").
 
FromMailAddr String Specifies the sender's e-mail address.
 
FromName String Specifies the sender's name.
 
IncludeObjectsInMail Boolean If you have included pictures or sound in the HTML message and want them to be embedded in the e-mail you must set this property to True. Then the objects will be coded in the message using the Base64 method. This property is ignored if DocumentType is 0.
 
ListUnsubscribe String If you want to add an unsubscribe field (List-Unsubscribe) to the e-mail header you can specify it here. The property must contain a URL or e-mail address. The string you specify must begin with a "<" character and end with a ">" character. Examples:
"<http://www.mydomain.com/unsubscribe/unsubscribe.aspx?email=test@test.com>"
"<mailto:unsubscribe@mydomain.com?subject=UNSUBSCRIBE>"
More information about the List-Unsubscribe field is available in this RFC document.
 
MailAddress String Specifies the e-mail address to use when logging in to a SMTP server.
 
MailPort Long Specifies the port number to use when connecting to the SMTP server. The default value for this property is 25 and normally you never need to change the value.
 
MailServer String Specifies the SMTP server to use when sending e-mails.
 
Password String Specifies a password, if needed, when connecting to an SMTP server. A password is normally not needed when login to an SMTP server because they often use another authentication system.
 
ReplyMailAddr String Specifies a reply e-mail address.
 
ReplyName String Specifies a reply name.
 
Subject String Specifies the subject to the e-mail message.
 
To String Specifies the e-mail address of the recipient.
 
ToName String Specifies the name of the recipient. This property can be empty if the name is unknown.
 
TransferEncoding Integer Specifies a transfer encoding method for the e-mail messages that will be sent. Can be one of the following values:
 
  0 - SevenBit ( Encode as 7-bit ASCII )
  1 - QuotedPrintable ( Encode as quoted-printable )
 
UseAuthentication Boolean Some SMTP servers require authentication with username and password before an e-mail can be sent via the server. If the server you are going to use requires it you can set this property to True and specify username and password via the UserName and Password properties.
.
UseLog Boolean Enables/disables using of a log file in the control. If this property has the value True a log file with the filename SLSMTPAX.LOG will be created. This log file contains detailed information about the SMTP communication between the client and the mail server. SMTP commands sent from the client to the server and reply code and reply messages from the server are stored in the log. More information about the SMTP commands can be read on this page.
 
In Windows XP and earlier the log file is stored in the Windows folder. In Windows Vista / 7 the log file is stored in the following folder: \Users\<User>\AppData\Roaming\SamLogic\Log Files
 
UserName String Specifies a user name, if needed, when connecting to an SMTP server. A user name is normally not needed when login to an SMTP server because they often use another authentication system.
 
XMailer String Specifies a text for the field "X-Mailer" in the e-mail message header. It can for example be the name of your application or any other value. 
 
 
Events
 
Name Description
ErrorOccured This event is fired if an error occurs when sending a mail.
 
MailServerReportedError This event is fired if the mail server reports an error or denies access. The parameter ReplyCode contains the error code that the mail server returned.
 
MailTransferApproved This event is fired if the login to the mail server was successful and we can use the server to send a mail.
 
SendCompleted This event is fired when the e-mail is sent and no errors have occurred.
 
 
Methods
 

Break ()

Cancels current operation. This method can be used to break the connection if the mail server is not responding in a given amount of time.

GetLastError () As Long

Returns an error code for the last error that occurred in the control. A list of possible error codes is available here.

GetLastReplyCode () As Long

Returns the last reply code from the mail server.

GetLastReplyMsg () As String

Returns the last reply message from the mail server.

HaveIncludeObjects () As Boolean

Returns True if the HTML message have pictures or sound included. If there is no such objects this method returns False.

SendMail () As Boolean

Sends the e-mail message. The method returns True if successful, or False otherwise. If an error occurs the error code can be obtained by calling the GetLastError method.
 

 
 
Example
 
SLSMTP1.DocumentType = 0                    ' We will send a plain text message
SLSMTP1.MailServer = "testserver.mail.com"  ' Specify the e-mail server (SMTP server)
SLSMTP1.MailAddress = "abc@mail.com"        ' Specify the login e-mail address
SLSMTP1.To = "test@test.com"                ' Specify the recipient's e-mail address
SLSMTP1.FromMailAddr = "mail@samlogic.com"  ' Specify the sender's e-mail address
SLSMTP1.FromName = "SamLogic"               ' Specify the sender's name
SLSMTP1.Subject = "Test"                    ' Specify the subject
SLSMTP1.Body = "This is a test message!"    ' Specify the body text
SLSMTP1.Attachment = "C:\windows\file.txt"  ' Specify a file that should be attached
SLSMTP1.SendMail                            ' Send the e-mail!
 
 
< Go back
 
 
SamLogic