当前位置:编程学习 > VB >>

懂VB的高手进来,谢谢,紧急!

做好软件后,我运行的时候,我一使用就出现下面的对话框!

然后我进行调试就出现下面图中的情况!高手请看看!

这是怎么回事?

答案:jmail是个组件,你需要有那个才得行。没有的话在网上找或想其它办法。

下面的代码能发送无附件的邮件(注意看下使用说明):

'要使用本模块必须在窗体添加 Winsock 控件,并且添加如下代码
'Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
' Winsock1.GetData Response
'End Sub

Option Explicit

Public Response As String

Dim First As String, Second As String, Third As String
Dim Fourth As String, Fifth As String, Sixth As String
Dim Seventh As String, Eighth As String, Ninth As String
Dim Start As Single, Tmr As Single, DateNow As String

Dim tmpWinsock As Winsock
Dim conTimeOut As Long


Const UserName = "" '这里设置用户名,现在的SMTP服务器都需要论证才能发邮件,就是你的邮箱用户名。
Const Password = "" '这里是设置密码。
'需要注意的是:用户名和密码都要使用BASE64编码。

Public Function SendEmail(ctlWinsock As Winsock, MailServerName As String, FromName As String, FromEmailAddress As String, ToName As String, ToEmailAddress As String, EmailSubject As String, EmailBodyOfMessage As String, Optional ResponsesEmail As String, Optional Timeout As Long = 30) As Boolean
'ctlWinsock Winsock控件
'MailServerName SMTP邮件服务器
'FromName 发送人的姓名
'FromEmailAddress 发送的EMail地址
'ToName 发送到的姓名
'ToEmailAddress 发送到的EMail地址
'EmailSubject 主题
'EmailBodyOfMessage 内容,注意邮件发送是以<CR><LF>.<CR><LF>结束,可能需要将内容中的.<CR><LF>替换掉
'ResponsesEmail 如果需要回复到非发送EMail,请在此指明

If Len(ResponsesEmail) = 0 Then ResponsesEmail = FromEmailAddress
conTimeOut = Timeout

Set tmpWinsock = ctlWinsock

If tmpWinsock.State = sckClosed Then
tmpWinsock.LocalPort = 0

DateNow = Format(Date, "Ddd") & ", " & Format(Date, "dd Mmm YYYY") & " " & Format(Time, "hh:mm:ss") & "" & " -0600"
First = "mail from: " + "<" + FromEmailAddress + ">" + vbCrLf ' Get who's sending E-Mail address
Second = "rcpt to: " + "<" + ToEmailAddress + ">" + vbCrLf ' Get who mail is going to
Third = "Date: " + DateNow + vbCrLf ' Date when being sent
Fourth = "From: " + FromName + "<" + ResponsesEmail + ">" + vbCrLf ' Who's Sending
Fifth = "To: " + ToName + "<" + ToEmailAddress + ">" + vbCrLf ' Who it going to
Sixth = "Subject: " + EmailSubject + vbCrLf ' Subject of E-Mail
Seventh = Replace(EmailBodyOfMessage, "." + vbCrLf, vbCrLf) + vbCrLf ' E-mail message body
Ninth = "X-Mailer: AnilSoft v 1.0" + vbCrLf ' What program sent the e-mail, customize this

Eighth = Fourth + Third + Ninth + Fifth + Sixth ' Combine for proper SMTP sending

tmpWinsock.Protocol = sckTCPProtocol ' Set protocol for sending
tmpWinsock.RemoteHost = MailServerName ' Set the server address
tmpWinsock.RemotePort = 25 ' Set the SMTP Port

tmpWinsock.Connect ' Start connection
If WaitFor("220") = False Then GoTo closeSock

tmpWinsock.SendData ("HELO cmechina" + vbCrLf)
If WaitFor("250") = False Then GoTo closeSock

tmpWinsock.SendData ("ehlo " + vbCrLf)
If WaitFor("250") = False Then GoTo closeSock

tmpWinsock.SendData ("auth login " + vbCrLf)
If WaitFor("334") = False Then GoTo closeSock

tmpWinsock.SendData (UserName + vbCrLf)
If WaitFor("334") = False Then GoTo closeSock

tmpWinsock.SendData (Password + vbCrLf)
If WaitFor("235") = False Then GoTo closeSock

tmpWinsock.SendData (First)
If WaitFor("250") = False Then GoTo closeSock

tmpWinsock.SendData (Second)
If WaitFor("250") = False Then GoTo closeSock

tmpWinsock.SendData ("data" + vbCrLf)
If WaitFor("354") = False Then GoTo closeSock

tmpWinsock.SendData (Eighth + vbCrLf)
tmpWinsock.SendData (Seventh + vbCrLf)
tmpWinsock.SendData ("." + vbCrLf)
If WaitFor("250") = False Then GoTo closeSock

tmpWinsock.SendData ("quit" + vbCrLf)
If WaitFor("221") = False Then GoTo closeSock
tmpWinsock.Close
SendEmail = True
Exit Function

closeSock:
Debug.Print "出错关闭" + vbCrLf
tmpWinsock.Close
SendEmail = False
Else
Debug.Print "Winsock.State = " + Str(tmpWinsock.State)
End If
End Function

Function WaitFor(ResponseCode As String) As Boolean
Start = Timer ' Time event so won't get stuck in loop
While Len(Response) = 0
Tmr = Timer - Start
DoEvents ' Let System keep checking for incoming response **IMPORTANT**
If Tmr > conTimeOut Then ' Time in seconds to wait
Debug.Print "SMTP service error, timed out while waiting for response"
WaitFor = False
Exit Function
End If
Wend
While Left(Response, 3) <> ResponseCode
DoEvents
If tmp = "421" Or tmp = "500" Or tmp = "502" Or tmp = "535" Then
'421 closing transmission channel
'500 Error: bad syntax
'502 Error: command not implemented
'535 Error: authentication failed
'421连接断开,500语法错误,502无效命令,535登录失败
Debug.Print Response
WaitFor = False
Exit Function
End If
Tmr = Timer - Start
If Tmr > conTimeOut Then
Debug.Print "SMTP service error, impromper response code. Code should have been: " + ResponseCode + vbCrLf + " Code recieved: " + Response
WaitFor = False
Exit Function
End If
Wend
Debug.Print "成功完成" + vbCrLf
Response = "" ' Sent response code to blank **IMPORTANT**
WaitFor = True
End Function

你需要把这个组件带走,

并且在别人的电脑上面注册

如果这个组件还需要注册表信息的话,记得要在使用前导入

这样就可以了,

DLL文件不存在或者没有注册。
echo 正在修复,这个过程可能需要几分钟,请稍候……
rundll32.exe advpack.dll /DelNodeRunDLL32 %systemroot%\System32\dacui.dll
rundll32.exe advpack.dll /DelNodeRunDLL32 %systemroot%\Catroot\icatalog.mdb
regsvr32 /s comcat.dll
regsvr32 /s asctrls.ocx
regsvr32 /s oleaut32.dll
regsvr32 /s shdocvw.dll /I
regsvr32 /s shdocvw.dll
regsvr32 /s browseui.dll
regsvr32 /s browseui.dll /I
regsvr32 /s msrating.dll
regsvr32 /s mlang.dll
regsvr32 /s hlink.dll
regsvr32 /s mshtml.dll
regsvr32 /s mshtmled.dll
regsvr32 /s urlmon.dll
regsvr32 /s plugin.ocx
regsvr32 /s sendmail.dll
regsvr32 /s mshtml.dll /i
regsvr32 /s scrobj.dll
regsvr32 /s corpol.dll
regsvr32 /s jscript.dll
regsvr32 /s msxml.dll
regsvr32 /s imgutil.dll
regsvr32 /s cryptext.dll
regsvr32 /s inseng.dll
regsvr32 /s iesetup.dll /i
regsvr32 /s cryptdlg.dll
regsvr32 /s actxprxy.dll
regsvr32 /s dispex.dll
regsvr32 /s occache.dll
regsvr32 /s iepeers.dll
regsvr32 /s urlmon.dll /i
regsvr32 /s cdfview.dll
regsvr32 /s webcheck.dll
regsvr32 /s mobsync.dll
regsvr32 /s pngfilt.dll
regsvr32 /s licmgr10.dll
regsvr32 /s hhctrl.ocx
regsvr32 /s inetcfg.dll
regsvr32 /s trialoc.dll
regsvr32 /s tdc.ocx
regsvr32 /s MSR2C.DLL
regsvr32 /s msident.dll
regsvr32 /s msieftp.dll
regsvr32 /s xmsconf.ocx
regsvr32 /s ils.dll
regsvr32 /s msoeacct.dll
regsvr32 /s wab32.dll
regsvr32 /s wabimp.dll
regsvr32 /s wabfind.dll
regsvr32 /s oemiglib.dll
regsvr32 /s directdb.dll
regsvr32 /s inetcomm.dll
regsvr32 /s msoe.dll
regsvr32 /s oeimport.dll
regsvr32 /s msdxm.ocx
regsvr32 /s dxmasf.dll
regsvr32 /s laprxy.dll
regsvr32 /s l3codecx.ax
regsvr32 /s acelpdec.ax
regsvr32 /s mpg4ds32.ax
regsvr32 /s danim.dll
regsvr32 /s Daxctle.ocx
regsvr32 /s lmr

上一个:VB6.0的教程适用于VB.net吗
下一个:一套VB试题,急需帮忙解决

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,