共享邮箱

时间:2017-06-27 13:40:27

标签: vba ms-access scrape

此代码适用于我自己的Outlook收件箱。它会抓取我想要的数据并将其放入访问数据库。

但是现在我想在我有权访问的SHARED邮箱中的文件夹上使用它,这可能吗?

假设我要查看的邮箱文件夹名为“WEBQUERY”,我要查看的共享邮箱名为mark.johnson@webquery.com(如果有帮助)

我得到的是“无法找到某个物体”

如何在共享邮箱中查找此文件夹而不是我的文件夹?

Option Compare Database

Sub getEmails()

Dim olApp As Outlook.Application
Dim olNamespace As Outlook.NameSpace
Dim k
Dim j
Dim x
Dim xXx
Dim olFolder As Outlook.MAPIFolder
Dim lngCol As Long
Dim olItem As Object ' Outlook.MailItem
Dim whichAccount As String
Dim objNS As Outlook.NameSpace
Dim BodyTxt As String
Dim BodyRow As String
Dim db As dao.Database
Dim rst As dao.Recordset
Dim strData As String

Set olApp = New Outlook.Application
Set olNamespace = olApp.GetNamespace("MAPI")
Set objNS = olApp.GetNamespace("MAPI")
Set olFolder = objNS.GetDefaultFolder(olFolderInbox).Folders("WEBQUERY")
Set rst = CurrentDb.OpenRecordset("SELECT * FROM email WHERE 1=0", 
dbOpenDynaset)

'table is called Email, Field called EmailData
For Each msg In olFolder.Items
Debug.Print msg.Body
BodyTxt = msg.Body

ArrayVariable = Split(BodyTxt, vbCrLf)

For W = 6 To 6
For x = 7 To 7
For Y = 10 To 10

'LBound(ArrayVariable) To UBound(ArrayVariable)

   rst.AddNew
   rst!EmailData = ArrayVariable(W)
   rst!EmailData3 = ArrayVariable(x)
   rst!EmailData2 = ArrayVariable(Y)
   rst!EmailData4 = "WEB"

   rst.Update

Next Y

Next x

Next W

Next
rst.Close

Set olApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
Set TempRst = Nothing

End Sub

0 个答案:

没有答案
相关问题