Get feild details from outlook to excel

THE_NEW_XL_GUY

New Member
Joined
Dec 20, 2017
Messages
47
Hello guys,

can someone help me to get this code work, it just freezes whenever I run macro.. and

in detail:

I have the code below which I got from internet and it is used to get data like subject, received time, sender name etc from specific date which I give as input

later I tweaked it to work with sharedmailbox mails only.

Now problem:

it just freezes and I also want to include categorized mails I mean on what category it is categorized, need that details as well..


Any help, I really appreciate it. thanks in advance!

Code:
Sub GetFromOutlook()
Dim OutlookApp As Outlook.Application
Dim OutlookNamespace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer

Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set olShareName = OutlookNamespace.CreateRecipient("email@exAMPLE.com")
Set Folder = OutlookNamespace.GetSharedDefaultFolder(olShareName, olFolderInbox)

i = 1
For Each OutlookMail In Folder.Items
    If OutlookMail.ReceivedTime >= Range("From_date").Value Then
       Range("eMail_subject").Offset(i, 0).Value = OutlookMail.Subject
        Range("eMail_date").Offset(i, 0).Value = OutlookMail.ReceivedTime
        Range("eMail_sender").Offset(i, 0).Value = OutlookMail.SenderName
        Range("eMail_size").Offset(i, 0).Value = OutlookMail.Size
        'Range("eMail_categories").Offset(i, 0).Value = OutlookMail.Categorize // is there way to get categorized mails with name of category 
        
        
        i = i + 1
    End If
Next OutlookMail
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
sorry one more last question, does adding folder names and sub folder names, gets me all mail details of folders inside sharedmailbox. I have so many folders and sub folders in sharedmail box and I need ALL the mails under folders and subfolders of sharedmailbox.

correct if am wrong please

Code:
 Set Folder = OutlookNamespace.GetSharedDefaultFolder(olShareName, olFolderInbox).folders("folder1").folders("folders2").folders("subfolder1underfolder2").folders("folder3")
 
Upvote 0
Hi @Domenic, sorry to bring this up,

can we get all mails of shared mail box( inbox, folders under inbox, sent folder, all remaining folders under inbox).

really need this. thanks!
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,023
Latest member
alabaz

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