台灣最大程式設計社群網站
線上人數
1613
 
會員總數:246138
討論主題:189722
歡迎您免費加入會員
討論區列表 >> 專欄文章 >> 夾檔寄信程式碼(CHOME)
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
夾檔寄信程式碼(CHOME)
價值 : 0 QP  點閱數:3295 回應數:0
樓主

站務人員 站長
門外漢
0 1580
542 9
發送站內信

捐贈 VP 給 站務人員
1.使用basp21元件上傳檔案

2.使用Jmail以便使用CID夾檔(離線可瀏覽圖形及聲音檔)

3.HTML格式寄送

4.朋友的通信錄放在資料表。。。


Ps:CDOMail不支援CID方式!

sendall.asp(取用通信錄資料表,將信寄給朋友,附加檔案)

<%

If request("Request_Method")="POST" Then

a=Request.TotalBytes

b=Request.BinaryRead(a)

Set obj=Server.CreateObject("basp21")



SenderName=obj.Form(b,"SenderName")

Sender=obj.Form(b,"Sender")



Domain=Request.ServerVariables("SERVER_NAME")

Response.Cookies("SenderName")=SenderName

Response.Cookies("SenderName").Domain=Domain

Response.Cookies("SenderName").Expires=date()+30



Response.Cookies("Sender")=Sender

Response.Cookies("Sender").Domain=Domain

Response.Cookies("Sender").Expires=date()+30



Subject=obj.Form(b,"Subject")

f1=obj.FormFileName(b,"flname")

Content=obj.Form(b,"Content")

Content=Replace(Content, chr(10)&chr(13), "
")

Content=Replace(Content, chr(13), "
")

dim fs,tetf

Set fs=Server.CreateObject("Scripting.FileSystemObject")

Set txtf=fs.OpenTextFile(Server.MapPath("sendmail.txt"))

Body=txtf.ReadAll

Body=Replace(Body, "++SenderName++", SenderName)

Body=Replace(Body, "++Sender++", Sender)

Body=Replace(Body, "++Subject++", Subject)

Body=Replace(Body, "++Content++", Content)

Body=Replace(Body, "++Now++", Now)

Set fs=Nothing



Dim jmail

Set jmail=Server.CreateObject("JMail.Message")

jmail.From=Sender

jmail.FromName=SenderName

jmail.Subject=Subject

Bgimg=jmail.AddAttachment(Server.MapPath("bg.gif"),true)

Bgmid=jmail.AddAttachment(Server.MapPath("061.mid"),true)

Title=jmail.AddAttachment(Server.MapPath("title.gif"),true)

Body=Replace(Body, "++Bgimg++", Bgimg)

Body=Replace(Body, "++Bgmid++", Bgmid)

Body=Replace(Body, "++Title++", Title)

jmail.AppendHTML Body

If f1 <> "" then

newf1=Mid(f1,InstrRev(f1,"\")+1)

filename="temp/"&newf1

leng=obj.FormSaveAs(b,"flname",Server.MapPath(filename))

if leng > 0 then jmail.addattachment (Server.MapPath(filename),true)

end if

response.write "<center>"

response.write
"<TABLE align=center border=1 bordercolordark=ffffff
bordercolorlight=999999 cellpadding=0 cellspacing=0 width=600>"

response.write "<tr bgcolor=cee7ff align=center><td>
<font color=008800 face=verdana>編號</td>"

response.write "<td><font color=008800 face=verdana>姓名</td>"

response.write "<td><font color=008800 face=verdana>伊媚兒</td>"

response.write "<td><font color=008800 face=verdana>電話</td></tr>"

Set conn=Server.CreateObject("ADODB.Connection")

Provider="Provider=Microsoft.Jet.OLEDB.4.0;"

DBPath="Data Source="&Server.MapPath("friends.mdb")

conn.Open Provider&DBPath

Set rs=Server.CreateObject("ADODB.Recordset")

SortSql="Select * From email where use=0"

rs.Open SortSql, conn, 1,3

Do until rs.EOF

jmail.AddRecipientBCC rs("email")

response.write "<tr><td align=right><font color=008800 face=verdana>"&rs("Recordno")&"</td>"

response.write "<td><font color=008800 face=verdana>"&rs("Fname")&"</td>"

response.write "<td><font color=008800 face=verdana>"&rs("email")&"</td>"

response.write "<td><font color=008800 face=verdana>Tel:"&rs("tel")&"</td></tr>"

rs.movenext

Loop

jmail.Send("ms6.hinet.net")

Response.write "</table>
"

Response.write "<center><font size=6 color=000088>信已全部寄出</font>

"

response.write "<a href=/index.asp?page="&page&"><font size=5>回首頁</font></a>"

Response.end

End If

%>

<html>

<head>

<title>好文與好有欣賞</title>

<meta http-equiv="Content-Type" content="text/html; charset=big5">

<link REL="stylesheet" HREF="style.css" TYPE="text/css">

</head>

<body bgcolor=e9e4d6 marginheight=5 marginwidth=5 leftmargin=5 topmargin=5>

<center>

<font size=7 color=000088 face=華康行書體>好文與所有好有分享</font>


<form action="sendall.asp" method="POST" name="MYFORM" ENCTYPE="multipart/form-data">

<TABLE align=center border=1 bordercolordark=ffffff
bordercolorlight=999999 cellpadding=0 cellspacing=0 width=88%>

<TR>
<td bgcolor=66ccff height=20 nowrap width=12% align=center>
<font color=0000cc face=新細明體 size=2>寄件者姓名</font></td>

<td bgcolor=66ccff width=88%>
<input name=SenderName value="<%=trim(Request.Cookies("SenderName"))%>"size=40 MAXLENGTH="30">
</td></TR>

<TR>
<td bgcolor=cee7ff height=20 nowrap align=center>
<font color=0000cc face=新細明體 size=2>寄件者e-mail</font></td>

<td bgcolor=cee7ff>
<input name="Sender" value="<%=trim(Request.Cookies("Sender"))%>" size="40" MAXLENGTH="50">
</td></TR>

<TR><td bgcolor=cee7ff nowrap align=center>
<font color=0000cc face=新細明體 size=2>信件標題</font></td>

<td bgcolor=cee7ff><input name="Subject" value="" size="50" MAXLENGTH="50">
</td></TR>

<TR><td bgcolor=cee7ff nowrap align=center>
<font color=0000cc face=新細明體 size=2>附加檔案</font></td>

<td bgcolor=cee7ff><input type="file" size="40" name="flname">
</td></TR>


<TR><td bgcolor=66ccff nowrap align=center valign=top>
<font color=0000cc face=新細明體 size=2>信件內容</font>
</TD>

<TD><textarea name=Content cols=70 rows=6></textarea></TD></TR>

</TABLE>

<INPUT TYPE=Submit value="填妥送出">
<INPUT TYPE=reset value="清除重填">
</form>

寄信的範本檔:sendmail.txt

<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=big5">

<html><head><title>寄語西風</title>

<meta http-equiv="Content-Type" content="text/html; charset=big5">

<style type="text/css"><!--

body,input,select,textarea,checkbox{font:9pt,新細明體}

A:link{color:#3333ff;font-family:"Verdana","serif";font-size:10pt;text-decoration:none}

A:hover{background-color:yellow;color:#004080;font-size:10pt;text-decoration:underline}

A:visited{color:#004080;font-size:10pt;text-decoration:none}

TD{font-family:"Verdana","serif";font-size:10pt}

--></style>

</head>

<body background=cid:++Bgimg++ bgcolor=FFFFF leftmargin=10 topmargin=10 marginwidth=10 marginheight=10>

<center>

<BGSOUND balance=0 loop=infinite src=cid:++Bgmid++ volume=-600>

<table width=560 border=0 cellspacing=0 cellpadding=0>

<tr><td align=center bgcolor=ffffff><img src=cid:++Title++><td></tr>

<tr height=30><td align=center bgcolor=aaf797>

<a href=http://chome.rich2000.com>寄語西風</a>

∥<a href=http://www.hand.com.tw/horse/web/chat.asp>E世情緣</a>

∥<a href=http://asp.pccu.edu.tw/Board_3/INDEX.ASP>藍色小鋪</a>

∥<a href=http://www.hand.com.tw/horse/web/chat.asp>黑調路線</a>

∥<a href=http://littlelove.uline.net/board>接近小愛</a></td></tr>

</table>

<table width=560 border=0 cellspacing=1 cellpadding=0 bgcolor=aaf797>

<tr><td align=center>

<table width=556 border=0 cellspacing=0 cellpadding=0 bgcolor=aaf797>

<tr><td align=center>

<tr bgcolor=eeeeee><td colspan=3>
<div align=right>寄件者:++SenderName++ 時間:++Now++</div>
<font size=4 color=008800 face=verdana>標題:++Subject++</font></td></tr>

<tr bgcolor=ffffff><td width=10> </td>

<td>
++Content++

</td><td width=10> </td></tr>

<tr height=25>
<td colspan=3 align=center bgcolor=aaf797>讓我們走入世界去,也讓世界走近我們來</td>
</tr>
</table>
</td></tr></table>
</body></html>
本篇文章發表於2001-05-04 17:27
目前尚無任何回覆
   

回覆
如要回應,請先登入.