Outlook VBA ... Send data til excel
HejJeg vil gerne kunne eksportere min indboks indhold til excel
Jeg har fundet følgende VBA kode på:
http://www.mrexcel.com/forum/showthread.php?t=63932
Men den fortæller mig at der er en fejl i linjen:
Compile error: Sub or funktion not defined ...
Cells(i, 1) = MItem.SenderName
Hvad er der galt og hvordan retter jeg det?
Sub Getinboxdetails()
Dim OutApp As Object 'Outlook.Application
Dim NmSpace As Object 'Outlook.NameSpace
Dim Inbox As Object 'Outlook.MAPIFolder
Dim MItem As Object 'Outlook.MailItem
Dim i As Long
Dim x As Integer
Dim Feedb As String
Set OutApp = CreateObject("Outlook.Application")
Set NmSpace = OutApp.GetNamespace("MAPI")
Set Inbox = NmSpace.GetDefaultFolder(6)
i = 1
'// In case of UNDELIVERABLES
On Error Resume Next
For Each MItem In Inbox.Items
DoEvents
'// Note Only looking for Items within THIS MONTH!
If Month(MItem.Subject) = Month(Now) Then
'If Err Then Err.Clear: GoTo N
i = i + 1
Cells(i, 1) = MItem.SenderName
Cells(i, 2) = MItem.Subject
Cells(i, 3) = MItem.UserProperties("IncidentType").Value
Cells(i, 4) = MItem.UserProperties("IncidentDescription").Value
End If
N: Next MItem
Set MItem = Nothing
Set Inbox = Nothing
Set NmSpace = Nothing
Set OutApp = Nothing
Set Attach = Nothing
End Sub