Sub
impOutlookTable()
Const
strMail
As
String
=
"***@********.de"
Dim
oApp
As
Outlook.Application
Dim
oMapi
As
Outlook.MAPIFolder
Dim
oMail
As
Outlook.MailItem
On
Error
Resume
Next
Set
oApp = GetObject(,
"OUTLOOK.APPLICATION"
)
If
(oApp
Is
Nothing
)
Then
Set
oApp = CreateObject(
"OUTLOOK.APPLICATION"
)
On
Error
GoTo
0
Set
oMapi = oApp.GetNamespace(
"MAPI"
).Folders(strMail).Folders(
"Posteingang"
)
Set
oMail = oMapi.Items(oMapi.Items.Count)
Dim
oHTML
As
MSHTML.HTMLDocument:
Set
oHTML =
New
MSHTML.HTMLDocument
Dim
oElColl
As
MSHTML.IHTMLElementCollection
With
oHTML
.Body.innerHTML = oMail.HTMLBody
Set
oElColl = .getElementsByTagName(
"table"
)
End
With
Dim
x
As
Long
, y
As
Long
For
x = 0
To
oElColl(0).Rows.Length - 1
For
y = 0
To
oElColl(0).Rows(x).Cells.Length - 1
Range(
"Reminder_Data!A1"
).Offset(x, y).Value = oElColl(0).Rows(x).Cells(y).innerText
Next
y
Next
x
Set
oApp =
Nothing
Set
oMapi =
Nothing
Set
oMail =
Nothing
Set
oHTML =
Nothing
Set
oElColl =
Nothing
End
Sub