对你是太菜的问题,对我就不是(再开一帖),顶者有分。

wdthkyou 2006-10-29 09:55:33
发邮件代码(主题、内容、附件),邮箱地址仔细检查过了,未有错,为何不能成功。请高手指点一下。
'引用Jmail 4.0 Library
Dim msg As jmail.Message
Dim strarr, contentId
Dim bln As Boolean
Dim intx As Integer

On Error GoTo ErrorHandle

Set msg = CreateObject("JMail.Message")
msg.Logging = True '启用邮件日志
msg.Charset = "gb2312" '邮件的文字编码为国标
msg.AddRecipient txtSendTo.Text '邮件收件人的地址

msg.From = txtaddress.Text '发件人的E-MAIL地址
msg.MailServerUserName = txtUserName.Text '登录邮件服务器所需的用户名
msg.MailServerPassWord = txtPassword.Text ''登录邮件服务器所需的密码
msg.subject = Format(Date, "yyyy年mm月dd") & "日调试信息" ' '邮件的标题
msg.Body = "详情见附件。" ' '邮件的内容

msg.Priority = 3 ' '邮件的紧急程度,1 为最快,5 为最慢。 3 为默认值,表示中等
msg.ContentTransferEncoding = "base64"
If txtFileName.Text <> "" Then '附件
If Dir(txtFileName.Text) <> "" Then
contentId = msg.AddAttachment(txtFileName.Text, True) '
End If
End If
If msg.Send(txtUserName.Text & ":" & txtPassword.Text & "@smtp.163.com") Then
MsgBox "OK!!"
End If
msg.Close
Set msg = Nothing
...全文
297 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
wdthkyou 2006-10-30
  • 打赏
  • 举报
回复
刚才开会去了,不好意思,让各位大虾久等了.
wdthkyou 2006-10-30
  • 打赏
  • 举报
回复
Dim cSubject As String, cBody As String, cFile As String
cSubject = Format(Date, "yyyy年mm月dd") & "日调试信息" ' '邮件的标题
cBody = "详情见附件。" ' '邮件的内容
If txtFileName.Text <> "" Then '附件
If Dir(txtFileName.Text) <> "" Then
cFile = Trim(txtFileName.Text) '附件文件的绝对地址
End If
End If
If SendMail("test200610@sina.com", "test20061030@163.com", "", "", cSubject, cBody, cFile, 3, "smtp.sina.com.cn", "test200610", "123456") = True Then
msgbox "发送成功!OK。"
End If
iland9876543210 2006-10-30
  • 打赏
  • 举报
回复
帮顶一下
zq972 2006-10-30
  • 打赏
  • 举报
回复
查看你用来发信的邮箱的用户名和密码

可以发送的
wdthkyou 2006-10-30
  • 打赏
  • 举报
回复
谢谢你的帮助,我试一试你的代码。
wdthkyou 2006-10-30
  • 打赏
  • 举报
回复
没有错提示!发送显示“ok”,按照代码应该成功了,可是邮箱就是没有收到。
zq972 2006-10-30
  • 打赏
  • 举报
回复
代码没有问题

你的程序什么错误提示?
迈克揉索芙特 2006-10-30
  • 打赏
  • 举报
回复
http://blog.csdn.net/Surpass/archive/2004/08/23/82373.aspx

Function SendMail(ByVal From As String, _
ByVal Recipient As String, _
ByVal RecipientCC As String, _
ByVal RecipientBCC As String, _
ByVal Subject As String, _
ByVal Body As String, _
ByVal Attachment As String, _
ByVal Priority As Integer, _
ByVal MailServer As String, _
ByVal MailServerUserName As String, _
ByVal MailServerPassWord As String) As Boolean

'From 发送地址
'Recipient 接收地址
'RecipientCC 副本抄送
'RecipientBCC 隐藏的副本抄送
'Subject 邮件标题
'Body 邮件内容
'Attachment 附件
'Priority 邮件的优先程度,从1到5
'MailServer SMTP服务器的IP地址或名称
'MailServerUserName SMTP服务器用户名
'MailServerPassWord SMTP服务器密码

Dim eMail As New jmail.Message
With eMail
.Logging = True '调用Log记录,供Debug用
.Silent = True

.MailServerUserName = MailServerUserName 'SMTP服务器用户名
.MailServerPassWord = MailServerPassWord 'SMTP服务器密码
.From = From '发送地址
.AddRecipient (Recipient) '接收地址
.AddRecipientBCC (RecipientBCC) '隐藏的副本抄送
.AddRecipientCC (RecipientCC) '副本抄送
.Subject = Subject '邮件标题
.Body = Body '邮件内容
If Len(Attachment) > 0 Then .AddAttachment (Attachment) '附件
.Priority = Priority

If eMail.Send(MailServer) Then '发送到SMTP服务器
SendMail = True
Else
SendMail = False
End If
End With
DoEvents
Set eMail = Nothing '销毁实例
End Function

wdthkyou 2006-10-30
  • 打赏
  • 举报
回复
大虾,上面显示调用,我的仍然没有成功,你调用成功了吗?
gsfcstx16 2006-10-29
  • 打赏
  • 举报
回复
学习一下
帮顶
Dunzip 2006-10-29
  • 打赏
  • 举报
回复
没有用过这东东。

wdthkyou 2006-10-29
  • 打赏
  • 举报
回复
增加了一句代码:
msg.FromName = "XXXX" '发送者姓名
尝试,提示发送成功,可是进入邮箱,未收到任何信息!
请高手指点一下。是不是附件不接受文本文件(我的附件yyyymmdd.txt)呀!
happy_sea 2006-10-29
  • 打赏
  • 举报
回复
没研究过这个东西,帮顶!

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧