VBA: Copy mail from shared outlook mailbox to excel

Kruijf

New Member
Joined
Jul 23, 2015
Messages
14
Hi all,

I have question, im looking for a macro that copies mail from a shared mailbox to excel. I do understand a little bit of VBA but im not good with writing my own macro's (yet). On the internet i found a macro that copies mail from specific folder in my default mail account, but that one does not work with shared mailboxes.

We need mails from specific folders in outlook in Excel so we can use the data for some reports that we make daily. Because it takes a while to copy those mails we would like to automate this with a macro. I did search on the internet but on a few occasions i found that people noted that it was not possible. We're using Office 2013.

So my questions are.
- Is it possible to do this with VBA?
- If so, does anybody have a macro that i can use for my situation?


I hope it's clear what we need, hopefully it's possible and somebody can send me in the right direction.
Thanks in advance.

Kind regards,
Tom
 
Hi RickXL,

I'm having the same issue as the original post, however, when I try to reference the shared mailbox, I get an Automation error. Any advice on this?
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi, i find this thread very helpful. I have a question thought. Is possible to work with multiple shared mailbox? Let’s say maybe 6 shared mailbox? with a same function of every time we copy the email, it will just populate the next empty row?
 
Upvote 0
Hi,
I have tried to start using the coding provided in the thread but keep getting the error on Set olFldr = objNS.Folders("xxx@xx.com"). It is a shared mailbox. I tried different mailboxes but it keeps getting stuck on the same line


Sub getEmails4()

Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olFldr As Outlook.MAPIFolder
Dim olItem As Object
Dim olMailItem As Outlook.MailItem

Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olFldr = objNS.Folders("xxx@xx.com")
Set olFldr = olFldr.Folders("Inbox")
Set olFldr = olFldr.Folders("Customers")
' Set olFldr = olFldr.Folders("A-C")
Set olFldr = olFldr.Folders("CustomerA")

For Each olItem In olFldr.Items
If olItem.Class = olMail Then
Set olMailItem = olItem
If olMailItem.ReceivedTime > Date Then Debug.Print olMailItem.Subject
End If
Next olItem

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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