| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1003 人关注过本帖
标题:VB不熟悉FolderManager.FolderExists(Rst!Accessory) 这句报错,提示未定义 ...
只看楼主 加入收藏
yiyaozjk
Rank: 2
等 级:论坛游民
帖 子:231
专家分:30
注 册:2010-3-10
结帖率:51.67%
收藏
已结贴  问题点数:20 回复次数:4 
VB不熟悉FolderManager.FolderExists(Rst!Accessory) 这句报错,提示未定义,要去引用 哪个部件?
下面这段 代码为何不能正常使用
我将网上的一段代码放到里面,却无法使用。
If FolderManager.FolderExists(Rst!Accessory) Then '判断文件夹是否存在 这句话报错了  提示未定义,要去引用 哪个部件    Set cFolder = FolderManager.GetFolder(("D:\1219\1"))
    Set cFile = cFolder.Files '建立文件集合
    For Each FileInfo In cFile
      jmail.Message.AddAttachment "D:\1219\1\" & FileInfo.Name
   Next
   End If
jmail.ClearRecipients '清除原来的地址

jmail.我声明了,但没看代码要声明这个FolderManager之类的东西

网上原代码是
Private Sub SendMail()
Dim jmail As New SMTPMail
Dim Conn As New ADODB.Connection
Dim Rst As New ADODB.Recordset, Rst1 As New ADODB.Recordset
Dim strRec As String, strRecCC As String
'On Error GoTo Err:
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Password=dir941421;User ID=kiss;Data Source=" & App.Path & "\OAData\OAData.mdb;Persist Security Info=True;Jet OLEDB:System database=" & App.Path & "\OAData\Secured.mdw"
'检测是否有要发送的信件
Rst.CursorLocation = adUseClient
Rst.Open "Select * From ztblMailBox Where BoxNum = 2", Conn, adOpenDynamic, adLockOptimistic, adCmdText
Do While Not Rst.EOF   '有要发送的信件
'先改变状态为已经发送失败,等发送成功后改变为成功
Conn.Execute "Update ztblMailBox Set BoxNum=3,SendState=False Where Id=" & Rst!id
'开始发送邮件Rst.CursorLocation = adUseClient
Rst1.Open "Select * From ztblMailConfig Where UserCode='" & Rst!UserCode & "'", Conn, adOpenDynamic, adLockOptimistic, adCmdText
If Rst1.EOF = False Then '有信箱存在
jmail.Sender = Rst1!MailName '取出发送者信箱名称
jmail.ServerAddress = Rst1!SmtpServer '服务器地址
jmail.ServerPort = "25"
jmail.SenderName = Rst1!Sender '取出发信人的姓名:汉字的也可以
jmail.Message.From = Rst1!MailName '来之何方
jmail.Message.FromName = Rst1!Sender '取出发信人的姓名:汉字的也可以
jmail.Message.Subject = Rst!Topic '标题
jmail.Message.Body = Rst!Content '内容
jmail.ClearAttachments '清除原来的附件
If FolderManager.FolderExists(Rst!Accessory) Then '判断文件夹是否存在 我照抄了,
   Set cFolder = FolderManager.GetFolder(Rst!Accessory)
   Set cFile = cFolder.Files '建立文件集合
   For Each FileInfo In cFile
     jmail.Message.AddAttachment Rst!Accessory & "\" & FileInfo.Name
   Next

End If
jmail.ClearRecipients '清除原来的地址
If Not IsNull(Rst!SendTo) Then
strRecCC = Rst!SendTo
If InStr(1, strRecCC, ";", vbTextCompare) <> 0 Then
strRec = Left(strRecCC, InStr(1, strRecCC, ";", vbTextCompare) - 1)
strRecCC = Mid(strRecCC, InStr(1, strRecCC, ";", vbTextCompare) + 1)
If InStr(1, strRecCC, "@", vbTextCompare) <> 0 Then
strRecCC = Replace(strRecCC, ";", "", 1, -1, vbTextCompare)
End If
End If
End If
jmail.Message.AddRecipient strRec
If strRecCC <> "" Then jmail.Message.AddRecipientCC strRecCC
jmail.Message.MailServerUserName = Left$(Rst1!MailName, InStr(1, Rst1!MailName, "@") - 1) '服务器的用户名称
jmail.Message.MailServerPassWord = Rst1!MailPass '密码验证
jmail.ContentTransferEncoding = "base64"
jmail.Encoding = "base64"
jmail.Message.Charset = "gb2312"
jmail.Message.Silent = True
jmail.Message.ContentType = "multipart/html" '文本还是网页
jmail.Logging = False '是否记录日志
If jmail.Message.Send(Rst1!SmtpServer) Then
   Conn.Execute "Update ztblMailBox Set SendState=True Where Id=" & Rst!id
End If
End If
Rst1.Close
Rst.MoveNext
DoEvents
Loop
Err:
Rst.Close
jmail.Close
Set jmail = Nothing '彻底释放Jmail
Unload Me
End Sub
搜索更多相关主题的帖子: 1219 
2012-11-06 20:43
yz1025
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:6
帖 子:491
专家分:919
注 册:2012-10-26
收藏
得分:10 
Try...First...
set FolderManager = CreateObject("Scripting.FileSystemObject")

or

References Microsoft Scripting Runtime
Dim FolderManager as new FileSystemObject

不要投我
2012-11-06 21:20
yiyaozjk
Rank: 2
等 级:论坛游民
帖 子:231
专家分:30
注 册:2010-3-10
收藏
得分:0 
  Dim cFolder As Scripting.Folders
  Dim cFile AS Scripting.files
   If FolderManager.FolderExists("D:\1219\1") Then '判断文件夹是否存在     能正常
        Set cFolder = FolderManager.GetFolder("D:\1219\1")
            Set cFile = cFolder.Files '建立文件集合   
                   上面这句话又报错了。。提示没有定义,我上面也定义了 Dim cFile AS files
Dim cFile  。是要定义成什么。
                For Each FileInfo In cFile
                    jmail.Message.AddAttachment "D:\1219\1\" & FileInfo.Name
                Next
     'jmail.ClearAttachments '清除原来的附件
  JMailstat = jmail.Send(MailServer)
2012-11-07 08:43
ccwu2
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:35
专家分:142
注 册:2012-11-2
收藏
得分:10 
'References Microsoft Scripting Runtime
Dim FolderManager As Variant, cFolder As Folder, cFile As File
Set FolderManager = CreateObject("Scripting.FileSystemObject")
If FolderManager.FolderExists("D:\1219\1") Then
    Set cFolder = varFSO.GetFolder("D:\1219\1")
    For Each cFile In cFolder.Files
        jmail.Message.AddAttachment cFile
    Next
endif
Set cFolder = Nothing
Set FolderManager = Nothing

[ 本帖最后由 ccwu2 于 2012-11-7 09:52 编辑 ]

还没遇过编不出来的代码,如果有那只是自己功力不足。
2012-11-07 09:43
ccwu2
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:35
专家分:142
注 册:2012-11-2
收藏
得分:0 
以下是引用yiyaozjk在2012-11-7 08:43:22的发言:

  Dim cFolder As Scripting.Folders
  Dim cFile AS Scripting.files
   If FolderManager.FolderExists("D:\1219\1") Then '判断文件夹是否存在     能正常
        Set cFolder = FolderManager.GetFolder("D:\1219\1")
            Set cFile = cFolder.Files '建立文件集合   
                   上面这句话又报错了。。提示没有定义,我上面也定义了 Dim cFile AS files 、Dim cFile  。是要定义成什么。
                For Each FileInfo In cFile
                    jmail.Message.AddAttachment "D:\1219\1\" & FileInfo.Name
                Next
     'jmail.ClearAttachments '清除原来的附件
  JMailstat = jmail.Send(MailServer)


FileInfo?

还没遇过编不出来的代码,如果有那只是自己功力不足。
2012-11-07 09:45
快速回复:VB不熟悉FolderManager.FolderExists(Rst!Accessory) 这句报错,提示未 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041467 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved