ActiveX: SLSMTP (Filename: SLSMTP.OCX)
![]()
| SLSMTP is an ActiveX
control 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 mail clients can see the
pictures and hear the sound when opening the message. You can also add
attachments to a mail. SLSMTP uses the SMTP protocol when communicating with the mail server. Some mail servers require a POP3 login before the SMTP services at the mail server can be used. If the 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. |
| 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. |
| 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. In Windows XP and earlier the log file is stored in the Windows folder. In Windows Vista 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 GetLastReplyCode
() As Long GetLastReplyMsg
() As String HaveIncludeObjects
() As Boolean SendMail ()
As Boolean |
Example
SLSMTP1.DocumentType =
0
' We will send a plain text message
SLSMTP1.MailServer =
"testserver.mail.com" ' Specify the mail
server (SMTP server)
SLSMTP1.MailAddress = "abc@mail.com"
' Specify the login mail address
SLSMTP1.To = "test@test.com"
' Specify the recipient's mail address
SLSMTP1.FromMailAddr = "mail@samlogic.com" '
Specify the sender's 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!
![]()