找回密码
 注册
搜索
热搜: 回贴

asp收发邮件的源码

2010-1-31 08:06| 发布者: admin| 查看: 50| 评论: 0|原作者: 江月

<% Set pop3 = Server.CreateObject( "JMail.POP3" )

'pop3的连接用户名,密码,pop3地址
pop3.Connect "username", "password", "mail.mydomain.com"

Response.Write( "你有" & pop3.count & " 封邮件。

" )

if pop3.count > 0 then
Set msg = pop3.Messages.item(1)
ReTo = ""
ReCC = ""

Set Recipients = msg.Recipients
separator = ", "

' 现在得到所有的收件人,并且存储

For i = 0 To Recipients.Count - 1
If i = Recipients.Count - 1 Then
separator = ""
End If

Set re = Recipients.item(i)
If re.ReType = 0 Then
ReTo = ReTo & re.Name & " (" & re.EMail & ")" &
separator
else
ReCC = ReTo & re.Name & " (" & re.EMail & ")" &
separator
End If
Next

'这个程序得到附件,并且保存到服务器的硬盘上。也可以返回附件的详细连接
Function getAttachments()
Set Attachments = msg.Attachments
separator = ", "

For i = 0 To Attachments.Count - 1
If i = Attachments.Count - 1 Then
separator = ""
End If

Set at = Attachments(i)
at.SaveToFile( "c:\EMail\attachments\" & at.Filename )
getAttachments = getAttachments & "" &_
at.FileName & "(" & at.Size & " bytes)" & "
" & separator
Next
End Function

%>



























邮件标题 <%= msg.Subject %>
发件人 <%= msg.FromName %>
收件人 <%= ReTO %>
抄送 <%= ReCC %>
附件 <%= getAttachments %>
内容
<%= msg.Body %>


<% end if

pop3.Disconnect

%>
<%@ 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
%>


邮件发送成功,谢谢使用!




最新评论

相关分类

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 19:30 , Processed in 0.209709 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部