none
Excel VBA to fetch data from outlook RRS feed

  • Question

  • Hi,

    i am using a code to track the mails in outlook and fetching them to excel.

    i am looking for a solution the check whether my mail is replied or not, if replied when was it replied and who was the sender of the mail.

    The code below is giving me information but hte date which is reflecting on the replied is giving me a wrong date.

    Sub GetDataFromOutlook()

    Dim OutlookApp As Outlook.Application
    Dim OutlookNamespace As Namespace
    Dim Folder As MAPIFolder
    Dim OutlookMail As Variant

    Dim oPA As Outlook.PropertyAccessor
    Dim oMail As Object
    Dim propName, Header As String


    Dim i As Integer

    Set OutlookApp = New Outlook.Application
    Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
    Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox)
    Set oMail = Folder.Items(1)
    Set oPA = oMail.PropertyAccessor

    propName = "http://schemas.microsoft.com/mapi/proptag/0x10820040"



    i = 1

    For Each OutlookMail In Folder.Items
        If OutlookMail.ReceivedTime >= Range("B1").Value Then
            Set oMail = Folder.Items(i)
            Set oPA = oMail.PropertyAccessor

            
            Range("A3").Offset(i, 0).Value = OutlookMail.Subject
            Range("C3").Offset(i, 0).Value = OutlookMail.ReceivedTime
            Range("B3").Offset(i, 0).Value = OutlookMail.SenderName
            Range("D3").Offset(i, 0).Value = oPA.GetProperty(propName)
            

            
            i = i + 1
        
        End If

    Next OutlookMail

    Set Folder = Nothing
    Set OutlookNamespace = Nothing
    Set OutlookApp = Nothing

    End Sub

    Please help

    Thursday, March 7, 2019 11:22 PM

All replies

  • Hi,

    i am using a code to track the mails in outlook and fetching them to excel.

    i am looking for a solution the check whether my mail is replied or not, if replied when was it replied and who was the sender of the mail.

    The code below is giving me information but hte date which is reflecting on the replied is giving me a wrong date.

    Sub GetDataFromOutlook()

    Dim OutlookApp As Outlook.Application
    Dim OutlookNamespace As Namespace
    Dim Folder As MAPIFolder
    Dim OutlookMail As Variant

    Dim oPA As Outlook.PropertyAccessor
    Dim oMail As Object
    Dim propName, Header As String


    Dim i As Integer

    Set OutlookApp = New Outlook.Application
    Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
    Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox)
    Set oMail = Folder.Items(1)
    Set oPA = oMail.PropertyAccessor

    propName = "http://schemas.microsoft.com/mapi/proptag/0x10820040"



    i = 1

    For Each OutlookMail In Folder.Items
        If OutlookMail.ReceivedTime >= Range("B1").Value Then
            Set oMail = Folder.Items(i)
            Set oPA = oMail.PropertyAccessor

            
            Range("A3").Offset(i, 0).Value = OutlookMail.Subject
            Range("C3").Offset(i, 0).Value = OutlookMail.ReceivedTime
            Range("B3").Offset(i, 0).Value = OutlookMail.SenderName
            Range("D3").Offset(i, 0).Value = oPA.GetProperty(propName)
            

            
            i = i + 1
        
        End If

    Next OutlookMail

    Set Folder = Nothing
    Set OutlookNamespace = Nothing
    Set OutlookApp = Nothing

    End Sub

    Please help


    Friday, March 8, 2019 11:40 AM
  • The code below is giving me information but hte date which is reflecting on the replied is giving me a wrong date.


    This description of the problem is too vague.  Be specific.  Exactly what do you mean by "wrong date".  Is it the received date on a mail item in the inbox?  Is it the date you are attempting to retrieve for the last verb executed?  How is it "wrong"?

    Friday, March 8, 2019 11:54 AM