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!
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