Error: Object doesn't support this property or method

kalpeshyogi93

New Member
Joined
Sep 17, 2016
Messages
3
Hi Excellers,

I am trying to fetch my email data into excel.
Some how I find the code from net but facing the error like object doesn't support.
I investigate and got to know might be its just because of access of multiple accounts.

Could you please help me with this:
Below is the code

Code:
Option Explicit
Sub ListOutlookEmailInfoExcel()
Dim oINS As Outlook.Namespace
Dim olTaskFolder As Outlook.MAPIFolder
Dim olTask As Outlook.TaskItem
Dim olItems As Outlook.Items
Dim xlApp As Excel.Application
Dim xlWb As Excel.Workbook
Dim x As Long
Dim arrHeaders As Variant
Set oINS = GetNamespace("MAPI")
Set olTaskFolder = oINS.GetDefaulFolder(olFolderInbox)
Set olItems = olTaskFolder.Items
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlWb = xlApp.Workbook.Add
On Error Resume Next
x = 2
arrHeaders = Array("Date Created", "Date received", "Subject", "Sender", "Sender's Email Address", "CC", "BCC", "Sender's Email Type", "Size", "Unread")
xlWb.Worksheets(1).Range("A1").Resize(1, UBound(arrHeaders)).Value = ""
Do
    With xlWb.Worksheets(1)
        If Not (olItems(x).Subject = "" And olItems(x).Creationtime = "") Then
            .Cells(x, 1).Value = olItems(x).Creationtime
            .Cells(x, 2).Value = olItems(x).Receivedtime
            .Cells(x, 3).Value = olItems(x).Subject
            .Cells(x, 4).Value = olItems(x).SenderName
            .Cells(x, 5).Value = olItems(x).SenderEmailAddress
            .Cells(x, 6).Value = olItems(x).CC
            .Cells(x, 7).Value = olItems(x).BCC
            .Cells(x, 8).Value = olItems(x).SenderEmailType 'Ex: Internal server; SMTP or SMFP? Internal Server
            .Cells(x, 9).Value = Format((olItems(x).Size / 1024) / 1024, "#,##0.00") & "MB"
            .Cells(x, 10).Value = olItems(x).Unread
            x = x + 1
            
            End If
        End With
Loop Until x >= olItems.Count + 1
Set oINS = Nothing
Set olTaskFolder = Nothing
Set olItems = Nothing
Set xlApp = Nothing
Set xlWb = Nothing
End Sub

Thank you in advance!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
It would be very helpful if anyone have any alternate option to fetch the same for generic emails which will provide me an option to select the date range of email sent and received. :)
 
Upvote 0

Forum statistics

Threads
1,223,706
Messages
6,173,998
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top