教学内容     HTML篇 | CSS篇 | VBScript篇 | JavaScript篇 | ASP篇 |

第九节外部组件

 

发布:刘声田   发布时间:2011-12-24  字体:【

一、W3 Jmail组件

  1.简介
W3 Jmail是Dimac公司推出的ASP收发信组件, 可以在ASP、VB、Delphi等应用程序中调用, 支持HTML、多收件人、抄送、暗送。
主要优点有: 支持发信认证SMTP服务器; 支持POP3收信; 支持PGP加密; 支持多邮件合并。
2.W3 Jmail组件的使用
(1)安装
方法1:通过给定的setup.exe程序安装
默认安装目录为:C:\Program Files\Dimac\W3Jmail4\
同时安装:使用手册和示例代码文件
方法2:通过注册的方式安装
拷贝jmail.dll到一个目录,运行regsvr32 jmail.dll
(2)卸载
卸载setup安装方式:控制面板-->添加/删除程序
卸载注册安装方式:regsvr32 /U jmail.dll
  3.常用方法
  (1)Send(mailServer, enque) : Boolean
  Sends the message. Mail servers is a string with one or more hostnames separated by a semicolon. A username and password can also be provided for each server in the format username:password@myhost.mydomain.com.
  (2)Body() : String
  Returns the message’s body.
  (3)Charset() : String
  The charset of the message. The default is "US-ASCII".
  (4)Date() : Date
  Returns the DateTime when the message was sent.
  (5)DeferredDelivery() : Date
  Sets deferred delivery of messages. If the mail server supports it the message won’t be delivered until this date and time.
  (6)ErrorCode() : Integer
  Contains the error code if message.silent is set to TRUE.
  (7)ErrorMessage() : String
  Contains the error message if message.silent is set to TRUE.
  (8)ErrorSource() : String
  Contains the error source if message.silent is set to TRUE.
  (9)From() : String
  Set or return sender’s e-mail address.
  (10)FromName() : String
  The sender’s name.
  (11)MailServerPassWord() : String
  Used to specify the password for SMTP server authentication if the mail server requires a user to log in.
  (12)MailServerUserName() : String
  Used to specify the username for SMTP server authentication if the mail server requires a user to log in.
  (13)Silent() : Boolean
  Set to TRUE, w3 JMail will not throw exceptions. Instead Message.send() will return TRUE or FALSE depending on the success of the operation.
  (15)Subject() : String
  Set or return the message’s subject.

二、ASPUpload组件

  1.简介
AspUpload is a COM+ component which enables an ASP application to capture, save and process files uploaded to the web server with a browser. The files are selected for uploading via an HTML POST form using the <INPUT TYPE=FILE> tag.
With AspUpload, you can add file upload functionality to your Web application in as little as 2 lines of ASP script. In addition to uploading, AspUpload offers a wide range of file management functions, including secure downloading, saving files in the database, permission and attribute management, image size extraction, file encryption, etc.
2.组件使用举例
两个文件Form1.asp和UploadScript1.asp
Form1.asp enables a user to select up to three files for uploading to the server.
 

<HTML>
<BODY BGCOLOR="#FFFFFF">
<h3>Simple Upload</h3>
<FORM METHOD="POST" ENCTYPE="multipart/form-data"     ACTION="UploadScript1.asp">
<INPUT TYPE="FILE" SIZE="40" NAME="FILE1"><BR>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE2"><BR>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE3"><BR>
<INPUT TYPE=SUBMIT VALUE="Upload!">
</FORM>
</BODY>
</HTML>

 

UploadScript1.asp includes the upload script.

<HTML>
<BODY>
<%
Set Upload = Server.CreateObject("Persits.Upload")
Count = Upload.Save("c:\upload")
Response.Write Count & " file(s) uploaded to c:\upload"
%>
</BODY>
</HTML>


 

  UploadScript1.asp代码解释
  The first line of the ASP script simply creates an instance of the AspUpload object. The second line calls the Save method of the component which actually performs the upload: it parses the information POSTed by the browser, figures out how many files are being uploaded, and saves them in a specified local directory on the server under their original names.
  The Save method returns the number of files successfully uploaded. In case of an error this method will throw an exception.