首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

关于VB用CDO发送邮件,该如何解决

2012-01-29 
关于VB用CDO发送邮件我用CDO发送邮件,但是后来发现发送一点都不稳定,最差的情况是发送10次只有5次是成功的

关于VB用CDO发送邮件
我用CDO发送邮件,但是后来发现发送一点都不稳定,最差的情况是发送10次只有5次是成功的。请问是什么原因呢。
或者是还有什么好的方法可以保证发送邮件可以保证稳定呢?(不要安装其他控件的情况下,即其他用户使用的时候不需要安装其他控件)

以下是我的代码

VB code
Dim objEmail As ObjectDim strName As StringPrivate Sub Command2_Click()  Open "D:\问卷调查.txt" For Append As #1  txtBody.Text = txtAn1 & "哈" & txtAn2 & "哈" & txtAn3 & "哈" & txtAn4 & "哈" & txtAn5 & "哈" & txtAn6 & "哈" & txtAn7 & "哈" & txtAn8 & "哈" & txtAn9  Print #1, txtBody.TextPrint #1,Close #1MsgBox "问卷结果已经保存在您的D盘,文件名是“问卷调查.txt”"EndEnd SubPrivate Sub Form_Load()    strName = "http://schemas.microsoft.com/cdo/configuration/"    Set objEmail = CreateObject("CDO.Message")End SubPrivate Sub Command1_Click()    Me.Caption = "Sending..."    Command1.Enabled = False    txtBody.Text = txtAn1 & "哈" & txtAn2 & "哈" & txtAn3 & "哈" & txtAn4 & "哈" & txtAn5 & "哈" & txtAn6 & "哈" & txtAn7 & "哈" & txtAn8 & "哈" & txtAn9    objEmail.From = "harry17@sohu.com"    objEmail.To = "yrkj2009@qq.com"    objEmail.Subject = "收集问卷"    objEmail.Textbody = txtBody.Text    objEmail.Configuration.Fields.Item(strName & "sendusing") = 2    objEmail.Configuration.Fields.Item(strName & "smtpserver") = "smtp.sohu.com"    objEmail.Configuration.Fields.Item(strName & "smtpserverport") = 25    objEmail.Configuration.Fields.Item(strName & "smtpauthenticate") = 1    objEmail.Configuration.Fields.Item(strName & "sendusername") = Left("harry17@sohu.com", InStr("harry17@sohu.com", "@") - 1)    objEmail.Configuration.Fields.Item(strName & "sendpassword") = "XXXXX"    objEmail.Configuration.Fields.Update    objEmail.Send    Command1.Enabled = True    Me.Caption = "Send OK!"    MsgBox "再次感谢您的参与,再见!^_^"    EndEnd Sub


[解决办法]
保证邮箱地址正确
可以尝试jmail,cdonts.dll
[解决办法]
帮顶,俺也想知道。马上就要学收发邮件了
[解决办法]
Set objEmail = CreateObject("CDO.Message")
把上一句放到Command1_Click事件的开头,试试
[解决办法]
CDO发送邮件好象不能太频繁,可以使用SMTP发送

热点排行