Help!

How to get the Mail Sent time using the Excel VBA

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Office applications RSS
Next:  split from 'lockergnome subscription management' ..  
Author Message
utkarshsi



Joined: Mar 22, 2012
Posts: 1



PostPosted: Thu Mar 22, 2012 5:05 am    Post subject: How to get the Mail Sent time using the Excel VBA


Using the following code just want to add the commented Line to work
Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim i As Integer
date2 = Date

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr1 = olNs.GetDefaultFolder(olFolderInbox)
Set Fldr = Fldr1.Folders("root")
i = 2

For Each olMail In Fldr.Items
receiveDate = CDate(olMail.ReceivedTime)
If InStr(olMail.Body, "Critical Error") > 0 And (receiveDate >= Date) Then 'Or _
'InStr(olMail.Subject, "DSR") > 0 Then
ActiveSheet.Cells(i, 1).Value = olMail.ReceivedTime
'ActiveSheet.Cells(i, 2).Value = olMail.SentTime
ActiveSheet.Cells(i, 3).Value = olMail.Subject


i = i + 1
End If
'olMail.Display
Next olMail

Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Office applications All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum