新微赢技术网
标题:
asp收发邮件的源码
[打印本页]
作者:
萧十一郎
时间:
2009-8-11 00:29
标题:
asp收发邮件的源码
<% Set pop3 = Server.CreateObject( "JMail.POP3" )</P><P>'pop3的连接用户名,密码,pop3地址
pop3.Connect "username", "password", "mail.mydomain.com"</P><P>Response.Write( "你有" & pop3.count & " 封邮件。<br/><br/>" )</P><P>if pop3.count > 0 then
Set msg = pop3.Messages.item(1)
ReTo = ""
ReCC = ""</P><P>Set Recipients = msg.Recipients
separator = ", "</P><P>' 现在得到所有的收件人,并且存储</P><P>For i = 0 To Recipients.Count - 1
If i = Recipients.Count - 1 Then
separator = ""
End If</P><P>Set re = Recipients.item(i)
If re.ReType = 0 Then
ReTo = ReTo & re.Name & " (<a href=""mailto:"& re.EMail &""">" & re.EMail & "</a>)" &
separator
else
ReCC = ReTo & re.Name & " (<a href=""mailto:"& re.EMail &""">" & re.EMail & "</a>)" &
separator
End If
Next</P><P>'这个程序得到附件,并且保存到服务器的硬盘上。也可以返回附件的详细连接
Function getAttachments()
Set Attachments = msg.Attachments
separator = ", "</P><P>For i = 0 To Attachments.Count - 1
If i = Attachments.Count - 1 Then
separator = ""
End If</P><P>Set at = Attachments(i)
at.SaveToFile( "c:\EMail\attachments\" & at.Filename )
getAttachments = getAttachments & "<a href=""/EMail/attachments/" & at.Filename &""">" &_
at.FileName & "(" & at.Size & " bytes)" & "</a>" & separator
Next
End Function</P><P>%>
<html>
<body>
<TABLE>
<tr>
<td>邮件标题</td>
<td><%= msg.Subject %></td>
</tr>
<tr>
<td>发件人</td>
<td><%= msg.FromName %></td>
</tr>
<tr>
<td>收件人</td>
<td><%= ReTO %></td>
</tr>
<tr>
<td>抄送</td>
<td><%= ReCC %></td>
</tr>
<tr>
<td>附件</td>
<td><%= getAttachments %></td>
</tr>
<tr>
<td>内容</td>
<td><pre><%= msg.Body %></pre></td>
</tr>
</TABLE>
</body>
</html></P><P><% end if</P><P>pop3.Disconnect</P><P>%>
<%@ Language=VBScript %>
<%
Dim JMail
t=Request("Body1")
t1=Request("Body2")
Set JMail=server.createobject("JMail.Message")
JMail.silent = true
JMail.Logging = true
JMail.Charset = "gb2312"
JMail.MailServerUserName = "liuixao" '输入smtp服务器验证登陆名 (邮局中任何一个用户的Email地址) -----改
JMail.MailServerPassword = "649" '输入smtp服务器验证密码 (用户Email帐号对应的密码) -----改
JMail.From = Request.Form("email") '发件人Email
JMail.FromName = Request.Form("name") '发件人姓名
JMail.AddRecipient "liu@.sina.net" '收件人Email,多个收件人,就重复多行 -----改
'JMail.AddRecipient "info@cnkl.net" '第二个收信地址----改成7个地址
JMail.Subject = Request.Form("subject") '信件主题
JMail.Body ="内容1:" &t& vbcrlf & "内容2:"&t1 '换行符 & vbcrlf &
JMail.Send ("你的邮件服务器地址") 'smtp服务器地址(mail.您的域名)-----改
JMail.Priority=2
JMail.Close()
set JMail = nothing
%>
<br/>
<p align="center">邮件发送成功,谢谢使用!</p>
作者:
ahwx
时间:
2010-1-16 15:05
我十目一行也还是看不懂啊
作者:
鸥飞007
时间:
2010-2-13 15:05
到你的~~贴吧收藏~~~我的发言~`找
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2