| Chapter 12 UtilitiesThis chapter contains the server-side objects File and SendMail .Table 12.1 summarizes the objects in this chapter. Table 12.1 Miscellaneous objects Object | DescriptionFile
| Provides access to the server's file system. | SendMail
| Provides functionality for sending electronic mail from your JavaScript application. | |
---|
FileLets an application interact with a physical file on the server.
Server-side object | | Implemented in | LiveWire 1.0 |
Created byThe File constructor:new File("path") Parameters
path | The path and filename in the format of the server's file system (not a URL path). |
DescriptionYou can use the File object to write to or read from a file on the server. For security reasons, you cannot programmatically access the file system of client machines.You can use the File object to generate persistent HTML or data files without using a database server. Information stored in a file is preserved when the server goes down.Exercise caution when using the File object. An application can read and write files anywhere the operating system allows. If you create an application that writes to or reads from your file system, you should ensure that users cannot misuse this capability.Specify the full path, including the filename, for the path parameter of the File object you want to create. The path must be an absolute path; do not use a relative path.If the physical file specified in the path already exists, the JavaScript runtime engine references it when you call methods for the object. If the physical file does not exist, you can create it by calling the open method.You can display the name and path of a physical file by calling the write function and passing it the name of the related File object.A pointer indicates the current position in a file. If you open a file in the a or a+ mode, the pointer is initially positioned at the end of the file; otherwise, it is initially positioned at the beginning of the file. In an empty file, the beginning and end of the file are the same. Use the eof , getPosition , and setPosition methods to specify and evaluate the position of the pointer. See the open method for a description of the modes in which you can open a file.You can use the prototype property of the File object to add a property to all File instances. If you do so, that addition applies to all File objects running in all applications on your server, not just in the single application that made the change. This allows you to expand the capabilities of this object for your entire server. Property Summary
prototype
| Allows the addition of properties to a File object. |
Method Summary
byteToString
| Converts a number that represents a byte into a string. | clearError
| Clears the current file error status. | close
| Closes an open file on the server. | eof
| Determines whether the pointer is beyond the end of an open file. | error
| Returns the current error status. | exists
| Tests whether a file exists. | flush
| Writes the content of the internal buffer to a file. | getLength
| Returns the length of a file. | getPosition
| Returns the current position of the pointer in an open file. | open
| Opens a file on the server. | read
| Reads data from a file into a string. | readByte
| Reads the next byte from an open file and returns its numeric value. | readln
| Reads the current line from an open file and returns it as a string. | setPosition
| Positions a pointer in an open file. | stringToByte
| Converts the first character of a string into a number that represents a byte. | write
| Writes data from a string to a file on the server. | writeByte
| Writes a byte of data to a binary file on the server. | writeln
| Writes a string and a carriage return to a file on the server. |
ExamplesExample 1. The following example creates the File object userInfo that refers to a physical file called info.txt . The info.txt file resides in the same directory as the application's .web file:userInfo = new File("info.txt") Example 2. In the following example, the File object refers to a physical file with an absolute path:userInfo = new File("c:datainfo.txt") Example 3. The following example displays the name of a File object onscreen.userInfo = new File("c:datainfo.txt") write(userInfo) PropertiesprototypeRepresents the prototype for this class. You can use the prototype to add properties or methods to all instances of a class. For information on prototypes, see Function.prototype .
Property of | File | Implemented in | LiveWire 1.0 |
MethodsbyteToStringConverts a number that represents a byte into a string.
Method of | File | Static | | Implemented in | LiveWire 1.0 |
SyntaxbyteToString(number) Parameters
number | A number that represents a byte. |
DescriptionUse the stringToByte and byteToString methods to convert data between binary and ASCII formats. The byteToString method converts the number argument into a string. Because byteToString is a static method of File , you always use it as File.byteToString() , rather than as a method of a File object you created.If the argument you pass into the byteToString method is not a number, the method returns an empty string. ExamplesThe following example creates a copy of a text file, one character at a time. In this example, a while loop executes until the pointer is positioned past the end of the file. Inside the loop, the readByte method reads the current character from the source file, and the byteToString method converts it into a string; the write method writes it to the target file. The last readByte method positions the pointer past the end of the file, ending the while loop. See the File object for a description of the pointer.// Create the source File object source = new File("c:datasource.txt") // If the source file opens successfully, create a target file if (source.open("r")) { target = new File("c:dataarget.txt") target.open("w") // Copy the source file to the target while (!source.eof()) { data = File.byteToString(source.readByte()) target.write(data); } source.close() } target.close() This example is similar to the example used for the write method of File . However, this example reads bytes from the source file and converts them to strings, instead of reading strings from the source file. See alsoFile.stringToByte clearErrorClears the current file error status.
Method of | File | Implemented in | LiveWire 1.0 |
SyntaxclearError() ParametersNone. DescriptionThe clearError method clears both the file error status (the value returned by the error method) and the value returned by the eof method. ExamplesSee the example for the error method. See alsoFile.error , File.eof closeCloses an open file on the server.
Method of | File | Implemented in | LiveWire 1.0 |
Syntaxclose() ParametersNone. DescriptionWhen your application is finished with a file, you should close the file by calling the close method. If the file is not open, the close method fails. This method returns true if it is successful; otherwise, it returns false. ExamplesSee the examples for the open method. See alsoFile.open , blob eofDetermines whether the pointer is beyond the end of an open file.
Method of | File | Implemented in | LiveWire 1.0 |
Syntaxeof() ParametersNone. DescriptionUse the eof method to determine whether the position of the pointer is beyond the end of a file. See File for a description of the pointer.A call to setPosition resulting in a location greater than fileObjectName.getLength places the pointer beyond the end of the file. Because all read operations also move the pointer, a read operation that reads the last byte of data (or character) in a file positions the pointer beyond the end of the file.The eof method returns true if the pointer is beyond the end of the file; otherwise, it returns false. ExamplesIn this example, a while loop executes until the pointer is positioned past the end of the file. While the pointer is not positioned past the end of the file, the readln method reads the current line, and the write method displays it. The last readln method positions the pointer past the end of the file, ending the while loop.x = new File("c:datauserInfo.txt") if (x.open("r")) { while (!x.eof()) { line = x.readln() write(line+"<br>"); } x.close(); } See alsoFile.getPosition , File.setPosition errorReturns the current error status.
Method of | File | Implemented in | LiveWire 1.0 |
Syntaxerror() ParametersNone Returns0 if there is no error.-1 if the file specified in fileObjectName is not openOtherwise, the method returns a nonzero integer indicating the error status. Specific error status codes are platform-dependent. Refer to your operating system documentation for more information. ExamplesThe following example uses the error method in an if statement to take different actions depending on whether a call to the open method succeeded. After the if statement completes, the error status is reset with the clearError method.userInput = new File("c:datainput.txt") userInput.open("w") if (userInput.error() == 0) { fileIsOpen() } else { fileIsNotOpen() } userInput.clearError() See alsoFile.clearError existsTests whether a file exists.
Method of | File | Implemented in | LiveWire 1.0 |
Syntaxexists() ParametersNone. ReturnsTrue if the file exists; otherwise, false. ExamplesThe following example uses an if statement to take different actions depending on whether a physical file exists. If the file exists, the JavaScript runtime engine opens it and calls the writeData function. If the file does not exist, the runtime engine calls the noFile function.dataFile = new File("c:datamytest.txt") if (dataFile.exists() ==true) { dataFile.open("w") writeData() dataFile.close() } else { noFile() } flushWrites the content of the internal buffer to a file.
Method of | File | Implemented in | LiveWire 1.0 |
Syntaxflush() ParametersNone. DescriptionWhen you write to a file with any of the File object methods (write , writeByte , or writeln ), the data is buffered internally. The flush method writes the buffer to the physical file. The flush method returns true if it is successful; otherwise, it returns false.Do not confuse the flush method of the File object with the top-level flush function. The flush function flushes a buffer of data and causes it to display in the client browser; the flush method flushes a buffer of data to a physical file. ExamplesSee the write method for an example of the flush method. See alsoFile.write , File.writeByte , File.writeln getLengthReturns the length of a file.
Method of | File | Implemented in | LiveWire 1.0 |
SyntaxgetLength() ParametersNone. DescriptionIf this method is successful, it returns the number of bytes in a binary file or characters in a text file; otherwise, it returns -1. ExamplesThe following example copies a file one character at a time. This example uses getLength as a counter in a for loop to iterate over every character in the file.// Create the source File object source = new File("c:datasource.txt") // If the source file opens successfully, create a target file if (source.open("r")) { target = new File("c:dataarget.txt") target.open("a") // Copy the source file to the target for (var x = 0; x < source.getLength(); x++) { source.setPosition(x) data = source.read(1) target.write(data) } source.close() } target.close() getPositionReturns the current position of the pointer in an open file.
Method of | File | Implemented in | LiveWire 1.0 |
SyntaxgetPosition() ParametersNone Returns-1 if there is an error. DescriptionUse the getPosition method to determine the position of the pointer in a file. See the File object for a description of the pointer. The getPosition method returns the current pointer position; the first byte in a file is byte 0. ExamplesThe following examples refer to the file info.txt , which contains the string "Hello World." The length of info.txt is 11 bytes.Example 1. In the following example, the first call to getPosition shows that the default pointer position is 0 in a file that is opened for reading. This example also shows that a call to the read method repositions the pointer.dataFile = new File("c:datainfo.txt") dataFile.open("r") write("The position is " + dataFile.getPosition() + "<BR>") write("The next character is " + dataFile.read(1) + "<BR>") write("The new position is " + dataFile.getPosition() + "<BR>") dataFile.close() This example displays the following information:The position is 0 The next character is H The new position is 1 Example 2. This example uses setPosition to position the pointer one byte from the end of the eleven-byte file, resulting in a pointer position of offset 10.dataFile = new File("c:datainfo.txt") dataFile.open("r") dataFile.setPosition(-1,2) write("The position is " + dataFile.getPosition() + "<BR>") write("The next character is " + dataFile.read(1) + "<BR>") dataFile.close() This example displays the following information:The position is 10 The next character is d Example 3. You can position the pointer beyond the end of the file and still evaluate getPosition successfully. However, a call to eof indicates that the pointer is beyond the end of the file.dataFile.setPosition(1,2) write("The position is " + dataFile.getPosition() + "<BR>") write("The value of eof is " + dataFile.eof() + "<P>") This example displays the following information:The position is 12 The value of eof is true See alsoFile.eof , File.open , File.setPosition openOpens a file on the server.
Method of | File | Implemented in | LiveWire 1.0 |
Syntaxopen("mode") Parameters
mode | A string specifying whether to open the file to read, write, or append, according to the list below. |
DescriptionUse the open method to open a file on the server before you read from it or write to it. If the file is already open, the method fails and has no effect. The open method returns true if it is successful; otherwise, it returns false.The mode parameter is a string that specifies whether to open the file to read, write, or append data. You can optionally use the b parameter anytime you specify the mode. If you do so, the JavaScript runtime engine on the server opens the file as a binary file. If you do not use the b parameter, the runtime engine opens the file as a text file. The b parameter is available only on Windows platforms.The possible values for mode are as follows:r[b] opens a file for reading. If the file exists, the method succeeds and returns true; otherwise, the method fails and returns false.
w[b] opens a file for writing. If the file does not already exist, it is created; otherwise, it is overwritten. This method always succeeds and returns true.
a[b] opens a file for appending (writing at the end of the file). If the file does not already exist, it is created. This method always succeeds and returns true.
r+[b] opens a file for reading and writing. If the file exists, the method succeeds and returns true; otherwise, the method fails and returns false. Reading and writing commence at the beginning of the file. When writing, characters at the beginning of the file are overwritten.
w+[b] opens a file for reading and writing. If the file does not already exist, it is created; otherwise, it is overwritten. This method always succeeds and returns true.
a+[b] opens a file for reading and appending. If the file does not already exist, it is created. This method always succeeds and returns true. Reading and appending commence at the end of the file.
When your application is finished with a file, you should close the file by calling the close method. ExamplesExample 1. The following example opens the file info.txt so an application can write information to it. If info.txt does not already exist, the open method creates it; otherwise, the open method overwrites it. The close method closes the file after the writeData function is completed.userInfo = new File("c:datainfo.txt") userInfo.open("w") writeData() userInfo.close() Example 2. The following example opens a binary file so an application can read data from it. The application uses an if statement to take different actions depending on whether the open statement finds the specified file.entryGraphic = new File("c:datasplash.gif") if (entryGraphic.open("rb") == true) { displayProcedure() } else { errorProcedure() } entryGraphic.close() See alsoFile.close readReads data from a file into a string.
Method of | File | Implemented in | LiveWire 1.0 |
Syntaxread(count) Parameters
count | An integer specifying the number of characters to read. |
DescriptionThe read method reads the specified number of characters from a file, starting from the current position of the pointer. If you attempt to read more characters than the file contains, the method reads as many characters as possible. This method moves the pointer the number of characters specified by the count parameter. See the File object for a description of the pointer.The read method returns the characters it reads as a string.Use the read method to read information from a text file; use the readByte method to read data from a binary file. ExamplesThe following example references the file info.txt , which contains the string "Hello World." The first read method starts from the beginning of the file and reads the character "H." The second read method starts from offset six and reads the characters "World."dataFile = new File("c:datainfo.txt") dataFile.open("r") write("The next character is " + dataFile.read(1) + "<BR>") dataFile.setPosition(6) write("The next five characters are " + dataFile.read(5) + "<BR>") dataFile.close() This example displays the following information:The next character is H The next five characters are World See alsoFile.readByte , File.readln , File.write readByteReads the next byte from an open file and returns its numeric value.
Method of | File | Implemented in | LiveWire 1.0 |
SyntaxreadByte() ParametersNone. DescriptionThe readByte method reads the next byte from a file, starting from the current position of the pointer. This method moves the pointer one byte. See the File object for a description of the pointer.The readByte method returns the byte it reads as a number. If the pointer is at the end of the file when you issue readByte , the method returns -1.Use the readByte method to read information from a binary file. You can use the readByte method to read from a text file, but you must use the byteToString method to convert the value to a string. Generally it is better to use the read method to read information from a text file.You can use the writeByte method to write data read by the readByte method to a file. ExamplesThis example creates a copy of a binary file. In this example, a while loop executes until the pointer is positioned past the end of the file. While the pointer is not positioned past the end of the file, the readByte method reads the current byte from the source file, and the writeByte method writes it to the target file. The last readByte method positions the pointer past the end of the file, ending the while loop.// Create the source File object source = new File("c:datasource.gif") // If the source file opens successfully, create a target file if (source.open("rb")) { target = new File("c:dataarget.gif") target.open("wb") // Copy the source file to the target while (!source.eof()) { data = source.readByte() target.writeByte(data); } source.close(); } target.close() See alsoFile.read , File.readln , File.writeByte readlnReads the current line from an open file and returns it as a string.
Method of | File | Implemented in | LiveWire 1.0 |
Syntaxreadln() ParametersNone DescriptionThe readln method reads the current line of characters from a file, starting from the current position of the pointer. If you attempt to read more characters than the file contains, the method reads as many characters as possible. This method moves the pointer to the beginning of the next line. See the File object for a description of the pointer.The readln method returns the characters it reads as a string.The line separator characters (" " and " " on Windows platforms and " " on UNIX platforms) are not included in the string that the readln method returns. The character is skipped; determines the actual end of the line.Use the readln method to read information from a text file; use the readByte method to read data from a binary file. You can use the writeln method to write data read by the readln method to a file. ExamplesSee File.eof See alsoFile.read , File.readByte , File.writeln setPositionPositions a pointer in an open file.
Method of | File | Implemented in | LiveWire 1.0 |
SyntaxsetPosition(position, reference) Parameters
position | An integer indicating where to position the pointer. | reference | (Optional) An integer that indicates a reference point, according to the list below. |
DescriptionUse the setPosition method to reposition the pointer in a file. See the File object for a description of the pointer.The position argument is a positive or negative integer that moves the pointer the specified number of bytes relative to the reference argument. Position 0 represents the beginning of a file. The end of a file is indicated by fileObjectName.getLength() .The optional reference argument is one of the following values, indicating the reference point for position :- 0: relative to beginning of file.
- 1: relative to current position.
- 2: relative to end of file.
- Other (or unspecified): relative to beginning of file.
The setPosition method returns true if it is successful; otherwise, it returns false. ExamplesThe following examples refer to the file info.txt , which contains the string "Hello World." The length of info.txt is 11 bytes. The first example moves the pointer from the beginning of the file, and the second example moves the pointer to the same location by navigating relative to the end of the file. Both examples display the following information:The position is 10 The next character is d Example 1. This example moves the pointer from the beginning of the file to offset 10. Because no value for reference is supplied, the JavaScript runtime engine assumes it is 0.dataFile = new File("c:datainfo.txt") dataFile.open("r") dataFile.setPosition(10) write("The position is " + dataFile.getPosition() + "<BR>") write("The next character is " + dataFile.read(1) + "<P>") dataFile.close() Example 2. This example moves the pointer from the end of the file to offset 10.dataFile = new File("c:datainfo.txt") dataFile.open("r") dataFile.setPosition(-1,2) write("The position is " + dataFile.getPosition() + "<BR>") write("The next character is " + dataFile.read(1) + "<P>") dataFile.close() See alsoFile.eof , File.getPosition , File.open stringToByteConverts the first character of a string into a number that represents a byte.
Method of | File | Static | | Implemented in | LiveWire 1.0 |
SyntaxstringToByte(string) Parameters
string | A JavaScript string. |
DescriptionUse the stringToByte and byteToString methods to convert data between binary and ASCII formats. The stringToByte method converts the first character of its string argument into a number that represents a byte. Because stringToByte is a static method of File , you always use it as File.stringToByte() , rather than as a method of a File object you created.If this method succeeds, it returns the numeric value of the first character of the input string; if it fails, it returns 0. ExamplesIn the following example, the stringToByte method is passed "Hello" as an input argument. The method converts the first character, "H," into a numeric value representing a byte.write("The stringToByte value of Hello = " + File.stringToByte("Hello") + "<BR>") write("Returning that value to byteToString = " + File.byteToString(File.stringToByte("Hello")) + "<P>") The previous example displays the following information:The stringToByte value of Hello = 72 Returning that value to byteToString = H See alsoFile.byteToString writeWrites data from a string to a file on the server.
Method of | File | Implemented in | LiveWire 1.0 |
Syntaxwrite(string) Parameters
string | A JavaScript string. |
DescriptionThe write method writes the string specified as string to the file specified as fileObjectName . This method returns true if it is successful; otherwise, it returns false.Use the write method to write data to a text file; use the writeByte method to write data to a binary file. You can use the read method to read data from a file to a string for use with the write method.Do not confuse the write method of the File object with the write function. The write function outputs data to the client browser; the write method outputs data to a physical file on the server. ExamplesThis example creates a copy of a text file, one character at a time. In this example, a while loop executes until the pointer is positioned past the end of the file. While the pointer is not positioned past the end of the file, the read method reads the current character from the source file, and the write method writes it to the target file. The last read method positions the pointer past the end of the file, ending the while loop. See the File object for a description of the pointer.// Create the source File object source = new File("c:datasource.txt") // If the source file opens successfully, create a target file if (source.open("r")) { target = new File("c:dataarget.txt") target.open("w") // Copy the source file to the target while (!source.eof()) { data = source.read(1) target.write(data); } source.close(); } target.flush() target.close() See alsoFile.flush , File.read , File.writeByte , File.writeln writeByteWrites a byte of data to a binary file on the server.
Method of | File | Implemented in | LiveWire 1.0 |
SyntaxwriteByte(number) Parameters
number | A number that specifies a byte of data. |
DescriptionThe writeByte method writes a byte that is specified as number to a file that is specified as fileObjectName . This method returns true if it is successful; otherwise, it returns false.Use the writeByte method to write data to a binary file; use the write method to write data to a text file. You can use the readByte method to read bytes of data from a file to numeric values for use with the writeByte method. ExamplesSee the example for the readByte method. See alsoFile.flush , File.readByte , File.write , File.writeln writeln Writes a string and a carriage return to a file on the server.
Method of | File | Implemented in | LiveWire 1.0 |
Syntaxwriteln(string) Parameters
string | A JavaScript string. |
DescriptionThe writeln method writes the string specified as string to the file specified as fileObjectName . Each string is followed by the carriage return/line feed character " " (" " on Windows platforms). This method returns true if the write is successful; otherwise, it returns false.Use the writeln method to write data to a text file; use the writeByte method to write data to a binary file. You can use the readln method to read data from a file to a string for use with the writeln method. ExamplesThis example creates a copy of a text file, one line at a time. In this example, a while loop executes until the pointer is positioned past the end of the file. While the pointer is not positioned past the end of the file, the readln method reads the current line from the source file, and the writeln method writes it to the target file. The last readln method positions the pointer past the end of the file, ending the while loop. See the File object for a description of the pointer.// Create the source File object source = new File("c:datasource.txt") // If the source file opens successfully, create a target file if (source.open("r")) { target = new File("c:dataarget.txt") target.open("w") // Copy the source file to the target while (!source.eof()) { data = source.readln() target.writeln(data); } source.close(); } target.close() Note that the readln method ignores the carriage return/line feed characters when it reads a line from a file. The writeln method appends these characters to the string that it writes. See alsoFile.flush , File.readln , File.write , File.writeByte
SendMailSends an email message.
Server-side object | | Implemented in | Netscape Server 3.0 | The To and From attributes are required. All other properties are optional. Created byThe SendMail constructor:new SendMail(); ParametersNone. DescriptionWhatever properties you specify for the SendMail object are sent in the header of the mail message.The SendMail object allows you to send either simple text-only mail messages or complex MIME-compliant mail or add attachments to your message. To send a MIME message, set the Content-Type property to the MIME type of the message.You can use the prototype property of the SendMail object to add a property to all SendMail instances. If you do so, that addition applies to all SendMail objects running in all applications on your server, not just in the single application that made the change. This allows you to expand the capabilities of this object for your entire server. Property Summary
Bcc
| Comma-delimited list of recipients of the message whose names should not be visible in the message. | Body
| Text of the message. | Cc
| Comma-delimited list of additional recipients of the message. | Errorsto
| Address to which to send errors concerning the message. Defaults to the sender's address. | From
| User name of the person sending the message. | Organization
| Organization information. | prototype
| Allows the addition of properties to a SendMail object. | Replyto
| User name to which replies to the message should be sent. Defaults to the sender's address. | Smtpserver
| Mail (SMTP) server name. Defaults to the value specified through the setting in the Administration server. | Subject
| Subject of the message. | To
| Comma-delimited list of primary recipients of the message. |
Method Summary
errorCode
| Returns an integer error code associated with sending this message. | errorMessage
| Returns a string associated with sending this message. | send
| Sends the mail message represented by this object. |
ExamplesExample 1: The following script sends mail to vpg and gwp, copying jaym, with the specified subject and body for the message:<server> SMName = new SendMail(); SMName.To = "[email protected], [email protected]" SMName.From = "[email protected]" SMName.Cc = "[email protected]" SMName.Subject = "The State of the Universe" SMName.Body = "The universe, contrary to what you may have heard, is in none too shabby shape. Not to worry! --me" SMName.send() </server> Example 2: The following example sends an image in a GIF file:sm = new SendMail(); sm.To = "satish"; sm.From = "[email protected]"; sm.Smtpserver = "fen.mcom.com"; sm["Errors-to"] = "satish"; sm["Content-type"] = "image/gif"; sm["Content-Transfer-Encoding"] = "base64"; file = new File("/u/satish/LiveWire/mail/banner.gif"); openFlag = file.open("r"); if ( openFlag ) { len = file.getLength(); str = file.read(len); sm.Body = str; } sm.send(); Example 3: The following example sends a multipart message:sm = new SendMail(); sm.To = "[email protected], [email protected]"; sm.From = "[email protected]"; sm.Smtpserver = "fen.mcom.com"; sm.Organization = "Netscape Comm Corp"; sm["Content-type"] = "multipart/mixed; boundary="------------8B3F7BA67B67C1DDE6C25D04""; file = new File("/u/satish/LiveWire/mail/mime"); openFlag = file.open("r"); if ( openFlag ) { len = file.getLength(); str = file.read(len); sm.Body = str; } sm.send(); The file mime has HTML text and an Microsoft Word document separated by the specified boundary. The resulting message appears as HTML text followed by the Microsoft Word attachment. PropertiesBccComma-delimited list of recipients of the message whose names should not be visible in the message.
Property of | SendMail | Implemented in | Netscape Server 3.0 |
BodyText of the message.
Property of | SendMail | Implemented in | Netscape Server 3.0 |
CcComma-delimited list of additional recipients of the message.
Property of | SendMail | Implemented in | Netscape Server 3.0 |
ErrorstoAddress to which to send errors concerning the message. Defaults to the sender's address.
Property of | SendMail | Implemented in | Netscape Server 3.0 |
FromUser name of the person sending the message.
Property of | SendMail | Implemented in | Netscape Server 3.0 |
OrganizationOrganization information.
Property of | SendMail | Implemented in | Netscape Server 3.0 |
prototypeRepresents the prototype for this class. You can use the prototype to add properties or methods to all instances of a class. For information on prototypes, see Function.prototype .
Property of | SendMail | Implemented in | LiveWire 1.0 |
ReplytoUser name to which replies to the message should be sent. Defaults to the sender's address.
Property of | SendMail | Implemented in | Netscape Server 3.0 |
SmtpserverMail (SMTP) server name. Defaults to the value specified through the setting in the Administration server.
Property of | SendMail | Implemented in | Netscape Server 3.0 |
SubjectSubject of the message.
Property of | SendMail | Implemented in | Netscape Server 3.0 |
ToComma-delimited list of primary recipients of the message.
Property of | SendMail | Implemented in | Netscape Server 3.0 |
MethodserrorCodeReturns an integer error code associated with sending this message.
Method of | SendMail | Implemented in | Netscape Server 3.0 |
Syntaxpublic errorCode(); ReturnsThe possible return values and their meanings are as follows:
0 | Successful send. | 1 | SMTP server not specified. | 2 | Specified mail server is down or doesn't exist. | 3 | At least one receiver's address must be specified to send the message. | 4 | Sender's address must be specified to send the message. | 5 | Mail connection problem; data not sent. |
errorMessageReturns a string associated with sending this message.
Method of | SendMail | Implemented in | Netscape Server 3.0 |
Syntaxpublic errorMessage(); ReturnsAn error string.sendSends the mail message represented by this object.
Method of | SendMail | Implemented in | Netscape Server 3.0 |
Syntaxpublic send (); ReturnsThis method returns a Boolean value to indicate whether or not the mail was successfully sent. If the mail was not successfully sent, you can use the errorMessage and errorCode methods to determine the nature of the error.This method returns a string indicating the nature of the error that occurred sending the message. |
| |