欢迎光临
我们一直在努力

用ASP发电子邮件

建站超值云服务器,限时71元/月

用asp发电子邮件

<%

dim strto, strsubject, strbody strings for recipient, subject, boby

dim objcdomail the cdo object

first well 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 weve 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 its 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 ive included samples of here:

objcdomail.cc = "kola100@163.com;kola100@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

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用ASP发电子邮件
分享到: 更多 (0)

相关推荐

  • 暂无文章