copy mails from shared outlook mailbox to excel

philam

New Member
Joined
Aug 9, 2017
Messages
3
</C:\users\bftd\desktop\vba>Hi Guys,

I have read other threads like this but the solutions doesn't work in my situation, I'm not sure what's the reason..im a newbie here..

What I'm looking for is a macro that copies mails from a shared group mailbox to excel .We're using Microsoft outlook office 16..
</C:\users\bftd\desktop\vba>
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
sorry I cannot post the snapshot of my error
btw here's my code, im not sure if this is correct


' Requires Tools-->References-->Microsoft Outlook 15.0 Object Library
Sub getEmails()
Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olFldr As Outlook.MAPIFolder
Dim olItem As Object
Dim olMailItem As Outlook.MailItem
Dim ws As Worksheet
Dim iRow As Long
Dim hdr As Variant

Set ws = ThisWorkbook.Worksheets("Sheet1")

Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")

Set olFldr = olNS.Folders("vcmaster@company.com")
Set olFldr = olFldr.Folders("Inbox")
Set olFldr = olFldr.Folders("J-VALSUPPORTING DOCS")
Set olFldr = olFldr.Folders("MANUAL TOUCHES")

ws.Cells.Clear
iRow = 2

Application.ScreenUpdating = False
For Each olItem In olFldr.Items
If olItem.Class = olMail Then
Set olMailItem = olItem
With olMailItem
ws.Cells(iRow, "A") = .Sender
ws.Cells(iRow, "B") = .SenderEmailAddress
ws.Cells(iRow, "C") = .SenderName
ws.Cells(iRow, "D") = .Subject
ws.Cells(iRow, "E") = .ReceivedTime
ws.Cells(iRow, "F") = .Categories
ws.Cells(iRow, "G") = .TaskCompletedDate
ws.Cells(iRow, "H") = olFldr.Name
iRow = iRow + 1
End With
End If
Next olItem
With ws
hdr = Array("Sender", "SenderEmailAddress", "SenderName", "Subject", "ReceicedTime", "Categories", "TaskCompletedDate", "Folder")
.Range("A1").Resize(, UBound(hdr)) = hdr
.Columns.AutoFit
End With
Application.ScreenUpdating = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,726
Messages
6,126,503
Members
449,316
Latest member
sravya

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