注册 登录
Office中国论坛/Access中国论坛 返回首页

的个人空间 http://www.office-cn.net/?0 [收藏] [复制] [分享] [RSS]

日志

OUTLOOK2000的收件箱内容复制到ACCESS数据库

已有 213 次阅读2008-1-27 09:33 |个人分类:VBA

自己做的, 请各位达人指点一下:

Sub CopyMessages()
Const MailBox = "个人文件夹"
Dim Cnt As New ADODB.Connection
Dim Mbox As New ADODB.Recordset
Dim fld As ADODB.Field

Dim Hist As New ADODB.Recordset
Dim ConnectString As String
Dim conn As New ADODB.Connection
Dim cntstring As String

ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" + "d:\vb\ado outlook\dbMessage.mdb" + ";Mode=Share Deny None"
conn.Open ConnectString
Hist.Open "tbl_Msg", conn, adOpenKeyset, adLockOptimistic '打开ACCESS数据库里的表


cntstring = "Provider=Microsoft.Jet.OLEDB.4.0;Outlook 9.0;MAPILEVEL=" & MailBox & "|收件箱;" & "DATABASE=C:\Temp\;"
Cnt.Open cntstring
Mbox.Open "select * from Official", Cnt '打开收件箱


Do Until Mbox.EOF
With Hist
    .AddNew
    !Msg_Sender = Mbox("来自")
    !Msg_Received = Mbox("已收到")
    !Msg_Subject = Mbox("主题")
    !Msg_Body = Mbox("内容")
    !Msg_Attch = Mbox("附件")
    .Update
End With
Mbox.MoveNext
Loop '把收件箱里的有关信息复制到ACCESS表


Mbox.Close
Set Mbox = Nothing
Cnt.Close
Set Cnt = Nothing
Hist.Close
Set Hist = Nothing
conn.Close
Set conn = Nothing
MsgBox "结束"
End Sub

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-29 23:31 , Processed in 0.065670 second(s), 14 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部