CW Email 1.0 Manual

Copyright (c) 1999 by The Network Connection, Inc.
All Rights Reserved


What is CW Email 4.0

CW Email 4.0 is an active server component for sending email messages using an external SMTP server in a CW application. CW Email 4.0 supports multiple recipients, multiple CC, multiple Bcc, multiple file attachments, and HTML format.

A demo copy of CW Email can be downloaded from http://www.olis.com/cw

System Requirements
General Requirements


Getting Started

Download and install the demo file above. The xControls.OCX file will be installed and registered in your windows\system directory. A demo CW 5 application will be installed in C:\Program Files\CWEmail.


Using CW Email

To use CW Email in a CW application, you must create a 32 bit application and place an instance of the Email control on your CW form. Follow the steps below to accomplish this.


Sample CW Application

CW Email is shipped with a sample CW application that allows you to create and send email messages with attachments over the Web. The application consists of the following files:

xControls.App - CW 5 Demo Application
xControls.Exe - Compiled CW 5 Demo

Sample CW Code:

?ole1{'Reset'} !clear adddresses and attachments
?ole1{'Host'}=loc:Host !set SMPT Mail host address
?ole1{'From'}=loc:From !set Senders Address
?ole1{'FromName'}=loc:FromName !set Senders Name
?ole1{'Subject'}=loc:Subject !set Subject
?ole1{'Body'}=loc:Body !set Body
?ole1{'IsHTML'}=loc:IsHTML !set Body contains HTML

?ole1{'AddAddressEmail'}=loc:Address !set Recipients address
?ole1{'AddAddressName'}=loc:AddressName !set Recipients name
?ole1{'AddAddress'} !add Recipients address/name (multiple Recipients ok)

if loc:Attachment<>'' then
  ?ole1{'AddAttachment'}=loc:attachment !add Attachment File (multiple attachments ok)
end

setcursor(cursor:wait)
?ole1{'Send'}
setcursor
if ?ole1{'ErrorNumber'}<>0 then
  message('Error: ' & ?ole1{'ErrorNumber'} & '|' & ?ole1{'ErrorDescription'})
else
  message('Your Email Has Been Sent!')
end

Object Reference
CW Email Properties
Property and Type Comments
Host As String Required. The internet address of a SMTP host to be used to send messages.
Port As Integer The SMTP port number. 25 by default.
From As String Required. The sender's email address.
FromName As String The sender's name.
Subject As String Message subject.
Body As String Message body. Can be in a text or HTML format. In the latter case, the IsHTML property must be set to True.
IsHTML As Boolean False by default. If set to True, CW Email will set the Content-Type of the message body to text/html. 
Priority As Integer Message priority. Valid values are 1 (high), 3 (normal) and 5 (low). 0 by default which means priority is not specified.
AddAddressEmail As String Adds an email address to the letter's To: list. 
AddAddressName As String Adds an email  full name to the letter's To: list. 
AddCCEmail As String Adds an email address Cc: list.
AddCCName As String Adds an email full name to the letter's Cc: list.
AddBCCName As String Adds an email full name to the letter's BCc: list.
AddReplyToEmail As String Adds an email address to the letter's Reply-To: list.
AddReplyToName As String Adds an email full name to the letter's Reply-To: list.
AddAttachment As String Adds a file to the list of file attachments to be sent with the message.
CW Email Methods
Method Name Comments
AddAddress Adds an email address and optionally the corresponding full name to the letter's To: list. 
AddCC Adds an email address and optionally the corresponding full name to the letter's Cc: list.
AddBcc Adds an email address and optionally the corresponding full name to the letter's Bcc: list.
AddReplyTo Adds an email address and optionally the corresponding full name to the letter's Reply-To: list.
AddAttachment Adds a file to the list of file attachments to be sent with the message.
Send Sends the message. Throws exceptions in case of an error. Check the ErrorNumber property after calling this method.  
Reset Clears all address and attachment lists so that a new message can be sent.  
ResetAll Same as Reset plus resets all properties to their respective default values.  
Error Codes
 
Error Code Description
1 Winsock initialization failed.
2 gethostbyname failed.
3 Socket creation failed.
4 Connection failed.
5 Sending data failed.
6 Error returned from SMTP server
7 Opening file failed.
8 Not enough memory.
9 Reading from file failed.
10 Host not specified
13 Invalid Priority value (generated by put_Priority)