I'm trying to list out all the subjects of emails in a particular folder. I am getting a Run time Error 13
as soon as item not mail item, i.e.appointment, etc.
Follow-up question:
1) How do reply to all to a latest email based the subject and email could be in Inbox or sent items.
2) How to loop in all emails in a folder, i.e. clicking "Click here to view more on Microsoft edge" give you access to all old emails.
Sub AccessInbox2()
'Early binding
Dim Olook As Outlook.Application ' to access all the libraries of outlook
Dim OmailItem As Outlook.MailItem ' To access emails in the inbox
Dim ONameSpace As Outlook.Namespace ' it is class which opens the gate for you to access all outlook folders. Unlike the Folder class, it exactly tells VBA which folder to use.
Dim Fol As Outlook.Folder ' Where we have emails with attachments stored
Dim Atmt As Outlook.Attachment ' a class which will help us in dealing wiht emails which as attachements
Dim TotalEmails As Long
Dim i As Integer
Set Olook = New Outlook.Application
Set OmailItem = Olook.CreateItem(olMailItem) 'to deal with emails
'messaging application protocal interface
i = 1
For Each OmailItem In Olook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Goldy").Items
'If TypeName(OmailItem) = "MailItem" Then
If OmailItem.Class = 43 Then
Sheet1.Cells(i, 7).Value = OmailItem.Subject
End If
i = i + 1
Next
End Sub
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…