用ASP发电子邮件

王朝asp·作者佚名  2006-01-08
宽屏版  字体: |||超大  

用ASP发电子邮件

CDONTS组件文字格式:

BodyFormat=0 html方式

BodyFormat=1 纯文本方式

设置编码:

MailFormat=0 MIME格式

MailFormat=1 连续的纯文本

objCDO.BodyFormat=0

objCDO.MailFormat=0

objCDO.To = sendto

objCDO.mailformat=0

objCDO.From = sender

objCDO.cc = cc

objCDO.Subject = subject

objCDO.AttachFile att_file

objCDO.Body = body

objCDO.Importance = 2

objCDO.Send

Set objCDO = Nothing

用ASP发电子邮件

<%

Dim strTo, strSubject, strBody 'Strings for recipient, subject, boby

Dim objCDOMail 'The CDO object

'First we'll read in the values entered

strTo = Request.Form("to")

'These would read the message subject and body if we let you enter it

'strSubject = Request.Form("subject")

'strBody = Request.Form("body")

strSubject = "Sample E-mail sent from X-Bit!"

' This is multi-lined simply for readability

strBody = "This message was sent from a sample at X-Bit. "

strBody = strBody & "It is used to show people how to send e-mail from an "

strBody = strBody & "Active Server Page. If you did not request this "

strBody = strBody & "e-mail yourself, your address was entered by one of "

strBody = strBody & "our visitors. We do not store these e-mail addresses."

strBody = strBody & " Please address all concerns to pplo@sina.com."

'Ok we've got the values now on to the point of the script.

'We just check to see if someone has entered anything into the to field.

'If it's equal to nothing we show the form, otherwise we send the message.

'If you were doing this for real you might want to check other fields too

'and do a little entry validation like checking for valid syntax etc.

If strTo = "" Then

%>

<FORM ACTION="./email_cdo.asp" METHOD="post">

Enter your e-mail address:<BR>

<INPUT TYPE="text" NAME="to" SIZE="30"></INPUT>

<!-- These would be used if we decided to let you edit them

Subject:

<INPUT TYPE="text" NAME="subject" SIZE="30"></INPUT><BR>

Message:

<TEXTAREA NAME="body" ROWS="10" COLS="40" WRAP="virtual"></TEXTAREA><BR>

-->

<INPUT TYPE="submit" VALUE="Send Mail!"></INPUT>

</FORM>

<%

Else

' Create an instance of the NewMail object.

Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

' Set the properties of the object

objCDOMail.From = "ppop@sina.com"

objCDOMail.To = strTo

objCDOMail.Subject = strSubject

objCDOMail.Body = strBody

' There are lots of other properties you can use.

' You can send HTML e-mail, attachments, etc...

' You can also modify most aspects of the message

' like importance, custom headers, ...

' Check the documentation for a full list as well

' as the correct syntax.

' Some of the more useful ones I've included samples of here:

'objCDOMail.Cc = "sundy100@163.com;sundy100@163.com"

'objCDOMail.Bcc = "wwew@sina.com;wwew@sina.com"

'objCDOMail.Importance = 1 '(0=Low, 1=Normal, 2=High)

'objCDOMail.AttachFile "c:\file.txt", "file.txt"

' Send the message!

objCDOMail.Send

' Set the object to nothing because it immediately becomes

' invalid after calling the Send method.

Set objCDOMail = Nothing

Response.Write "Message sent to " & strTo & "!"

End If

%>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有