Installation Table of Attributes Step by Step Example
Description
This activex component provides the services to send SMTP email. There are several Attributes and methods to this component. You can use this component to make your activeX capable application send email, complete with attachments. It is a pretty simple component on the outside. There is no user-interface to this component. Any user-interface required by your application is your responsibility. This component provides only the middle tier component support.
The component uses a low level windows socket connection to send email to an email MailServer that is defined by the MailServer attribute. This means that ANY application that has TCP/IP and Winsock capabilities along with support for ActiveX components may utilize this component to send email.
Attributes with an asterisk are assignable.
Installation:To install this component run:
C:\WINDOWS\SYSTEM\REGSVR32 AWTSMTP.DLL
in the directory where the component is installed. Regsvr32 may be located somewhere else on your machine. You will need to find it before attempting installation of this component. When running under Windows 95, the machine MUST have DCOM for Windows 95 installed for this component to work.
Attribute | Assignable | Data Type | Description |
---|---|---|---|
Body | Yes | String | the body of the email message as a string |
CCList | No | String | the cc list as a coma delimited string |
CLASSID | No | String | the Class name as "AWTSMTP" |
MailServer | Yes | String | the address of the mail server to be used to send this message |
ReplyTo | Yes | String | the reply to address |
ReplyToName | Yes | String | the name of the person to reply to |
Subject | Yes | String | the subject of the email message |
ToAddress | Yes | String | the primary email address to send this email to |
ToName | Yes | String | the name of the primary addressee for this email |
ToCC | Yes (Write Only) | String | another email address to send this email to |
Method | Returns | Description |
---|---|---|
AddAttachment | Add an attachment to a mail message | |
AddRecipient | Add a recipient to the list of people to send this email to | |
SendMail | hResult | the method used to send the email |
The following example shows how to:
- Create the SMTP Object
- Set up the mail server to use
- Set up who is sending the email
- Add the subject and the body of the email
- Set up who is receiving the email
- Adding Attachments to the email
- Sending the email
Step 1
'The next line creates the object using Visual Basic
Set SMTP = CreateObject("AWT.SMTP")
'The next line creates the object on the server using ASP VBScript
Set SMTP = Server.CreateObject("AWT.SMTP")
'The next line creates the object using CA-Visual Objects
SMTP = OLEAutoObject{"AWT.SMTP"}
Step 2
'Add the domain address of the mailserver
SMTP.MailServer = "mail.midtier.com"
Step 3
'Add the Reply to address
SMTP.Replyto = "john@midtier.com"
'Add the name of the person to reply to
SMTP.ReplytoName = "John Smith"
Step 4
'Add the subject of the email
SMTP.Subject = "Requested Files"
'Add the body of the email message
SMTP.Body = "Please read the readme.txt file which I've attached...."
Step 5
'Add the address to send the email to
SMTP.ToAddress = cAddr
Step 6
' add the attachment
SMTP.AddAttachment( "README.TXT" )
Step 7
' and send the email message
hResult = SMTP.SendMail()
That's all there is to it. If you want to add a user interface. It's up to you, how you want that interface to look for your clients
Add an attachment to a mail message
sFile
file to attach
This method adds a file as a binary attachment to a mail message. The file will be encoded using Base64 encoding and sent as a MIME attachment to the message.
The following example shows how to attach 5 files to a mail message.
The message will be sent to the user id specified in cAddr:
Set SMTP = CreateObject("AWT.SMTP")
'Add the address of the mailserver
SMTP.MailServer = "mail.midtier.com"
'Add the Reply to address
SMTP.Replyto = "john@midtier.com"
'Add the name of the person to reply to
SMTP.ReplytoName = "John Smith"
'Add the subject of the email
SMTP.Subject = "Requested Files"
'Add the body of the email message
SMTP.Body = "Here are the files you requested...."
'Add the address to send the email to
SMTP.ToAddress = cAddr
' add the five attachments
SMTP.AddAttachment( "MENU.DOC"
)
SMTP.AddAttachment( "LEASE.XLS" )
SMTP.AddAttachment( "ARCHIVE.ZIP" )
SMTP.AddAttachment( "PICTURE.GIF" )
SMTP.AddAttachment( "README.TXT" )
' and send the email message
hResult = SMTP.SendMail()
Add a recipient to the list of people to send this email to
cTo
the email address to
add to the recipient list
[cName]
the name of the person
who holds this email address
The following is a Visual Basic example of how to add a recipient to an email
Set SMTP = CreateObject("AWT.SMTP")
'Add the address to send the email to
'This would include the email address and the name of the 'person to send it to
SMTP.AddRecipient cAddr, cName
the method used to send the email
hResult - 0 if successful, otherwise standard COM errors
The following example shows how to attach 5 files to a mail message. The message will be sent to the user id specified in cAddr
Set SMTP = CreateObject("AWT.SMTP")
'Add the address of the mailserver
SMTP.MailServer = "mail.midtier.com"
'Add the Reply to address
SMTP.Replyto = "john@midtier.com"
'Add the name of the person to reply to
SMTP.ReplytoName = "John Smith"
'Add the subject of the email
SMTP.Subject = "Requested Files"
'Add the body of the email message
SMTP.Body = "Here are the files you requested...."
'Add the address to send the email to
SMTP.ToAddress = cAddr
' add the five attachments
SMTP.AddAttachment( "MENU.DOC" )
SMTP.AddAttachment( "LEASE.XLS" )
SMTP.AddAttachment( "ARCHIVE.ZIP" )
SMTP.AddAttachment( "PICTURE.GIF" )
SMTP.AddAttachment( "README.TXT" )
' and send the email message
hResult = SMTP.SendMail()
String - the cc list as a coma delimited string
The following is a Visual Basic example of accessing the cc list of an email message to be sent. The message will be sent to the all of those email addresses in the Addrecipient calls.
Set SMTP = CreateObject("AWT.SMTP")
'Add the address to send the email to
SMTP.AddRecipient "mike@midtier.com"
SMTP.AddRecipient "erik@midtier.com"
SMTP.AddRecipient "rick@midtier.com"
'cCCList would be "erik@midtier.com,rick@midtier.com"
'notice that mike@midtier.com is not in the cc list, he is
'the primary address or SMTP.ToAddress
cCCList = SMTP.CCList
String - Assign a cc to the list of recipients. Using this method does not allow you to add a nickname to the recipient
The following is a Visual Basic example of how to assign a cc address to an email
Set SMTP = CreateObject("AWT.SMTP")
SMTP.ToAddress "george@midtier.com", "George Smith"
'Add the cc address to send the email to
SMTP.ToCC = "erik@midtier.com"
String - the Class name as "AWTSMTP"
this attribute can be helpful in situations where the object is an IDispatch object. This attribute allows you to test to make sure that the IDispatch COM object that you have is the right class of object
String - the address of the mail server to be used to send this message
There is a chance that you will receive an error 571 when you try to send email. The reason for this error is that the mail server that you are trying to use does not allow users outside of it's own network to use it's mail server services. Talk to your mail service provider to see what you can do about it. In this case you must specify a mail server that allows you to connect to it.
The following Visual Basic example shows how to assign a mail server to a mail message.
Set SMTP = CreateObject("AWT.SMTP")
'Add the address of the mailserver
SMTP.AWTMailServer = "mail.midtier.com"
String - The reply to address
This is the email address that will be used when a reply is made to this email message.
The following Visual Basic example shows how to set the Replyto address and Replyto Name of a mail message.
Set SMTP = CreateObject("AWT.SMTP")
'Add the Reply to address
SMTP.Replyto = "john@midtier.com"
'Add the name of the person to reply to
SMTP.ReplytoName = "John Smith"
String - the name of the person to reply to
The following Visual Basic example shows how to set the Replyto address and Replyto Name of a mail message.
Set SMTP = CreateObject("AWT.SMTP")
'Add the Reply to address
SMTP.Replyto = "john@midtier.com"
'Add the name of the person to reply to
SMTP.ReplytoName = "John Smith"
String - the subject of the email message
The following is a Visual Basic example of how to Attribute* the subject of an email
Set SMTP = CreateObject("AWT.SMTP")
'Add the subject of the email
SMTP.Subject = "Requested Files"
String - the primary email address to send this email to
The following is a Visual Basic example of how to assign the To Address of an email
Set SMTP = CreateObject("AWT.SMTP")
'Add the address to send the email to
'This would include the email address and the name
'of the person to send it to
SMTP.ToAddress = "mike@midtier.com"
String - the name of the primary addressee for this email
The following is a Visual Basic example of how to assign the ToName of an email
Set SMTP = CreateObject("AWT.SMTP")
'Add the address to send the email to
'This would include the email address and the name
'of the person to send it to
SMTP.ToAddress = "mike@midtier.com"
SMTP.Toname = "Mike and the Mechanics"
String - Assign the body of the email message
The message will be sent to the user id specified in cAddr
Set SMTP = CreateObject("AWT.SMTP")
'Add the address of the mailserver
SMTP.MailServer = "mail.midtier.com"
'Add the Reply to address
SMTP.Replyto = "john@midtier.com"
'Add the name of the person to reply to
SMTP.ReplytoName = "John Smith"
'Add the subject of the email
SMTP.Subject = "Requested Files"
'Add the body of the email message
SMTP.Body = "Here are the files you requested...."
'Add the address to send the email to
SMTP.ToAddress = cAddr
' and send the email message
hResult = SMTP.SendMail()