pratiksuhasaria
New Member
- Joined
- Mar 26, 2019
- Messages
- 24
Hi All
I want to import mails from my outlook inbox to excel sheet depending on subject line i.e. if and only if subject line contains text APPROVED or CLARIFICATION at the start of subject.
Subject : APPROVED xyzz.....
CLARIFICATION abc.....
only this type of mail need to be extracted from inbox.
I have following code in which I need some this changes:
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 Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox)
i = 1
For Each OutlookMail In Folder.Items
With ThisWorkbook.Worksheets("TechnicalSheet").Range("B" & i + 1)
.NumberFormat = xlShortdate
.Value = DateValue(OutlookMail.ReceivedTime)
End With
ThisWorkbook.Worksheets("TechnicalSheet").Range("A" & i + 1).Value = OutlookMail.Subject
i = i + 1
Next OutlookMail
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
End Sub
Please help me
I want to import mails from my outlook inbox to excel sheet depending on subject line i.e. if and only if subject line contains text APPROVED or CLARIFICATION at the start of subject.
Subject : APPROVED xyzz.....
CLARIFICATION abc.....
only this type of mail need to be extracted from inbox.
I have following code in which I need some this changes:
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 Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox)
i = 1
For Each OutlookMail In Folder.Items
With ThisWorkbook.Worksheets("TechnicalSheet").Range("B" & i + 1)
.NumberFormat = xlShortdate
.Value = DateValue(OutlookMail.ReceivedTime)
End With
ThisWorkbook.Worksheets("TechnicalSheet").Range("A" & i + 1).Value = OutlookMail.Subject
i = i + 1
Next OutlookMail
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
End Sub
Please help me