一般邮箱发送邮件发送端口都是默认为25,但gmail邮箱比较特别,默认端口是465,而且如果代码中使用gmail邮箱发送,还需做一些设置,看如下介绍: Sub SendMail(MailSubject,MailContent,ReviceMail) .Item(StrName & "sendusing") = 2
首先我们在gmail邮箱中做下设置,登录gmail邮箱后
单击右上角设置标签-->转发和pop/imap-->启用imap访问。
OK,接下来再找一个可以设置端口的发送组件,jmail组件我没找到解决方案,我们来用CDO.Message吧,看如下函数,直接套用就行了。
以下是代码:
StrName = "http:"&"//schemas.microsoft.com/cdo/configuration/"
Set Email = server.CreateObject("CDO.Message")
Email.From = "noonenet.cn@gmail.com"
Email.To = ReviceMail
Email.BodyPart.Charset = "gb2312"
Email.Subject = MailSubject
Email.HtmlBody = MailContent
with Email.Configuration.Fields
.Item(StrName & "smtpserver") = "smtp.gmail.com"
.Item(StrName & "smtpserverport") = 465
.Item(StrName & "smtpauthenticate") = 1
.Item(StrName & "smtpusessl") = 1
.Item(StrName & "sendusername") = "你的gmail帐户"
.Item(StrName & "sendpassword") = "gmail帐户密码"
.Update
End With
Email.send
End Sub
参数说明:
MailSubject -- 邮件主题 MailContent -- 邮件内容 ReviceMail -- 邮件接收地址
这样就可以在网页里使用gmail邮箱发送邮件了。
原载: No.1网络工作室 http://www.noonenet.cn/