Enable outlook library in reference and use this code. you can change the 
date criteria to get the updated mails. 

Sub GetFromInbox()

    Dim olApp As Outlook.Application
    Dim olNs As Namespace
    Dim Fldr As MAPIFolder
    Dim olMail As Variant
    Dim i As Integer

    Set olApp = New Outlook.Application
    Set olNs = olApp.GetNamespace("MAPI")
    'Outlook provides no built-in way to get a folder if all you know is 
its name.
    'This sample for getting a MAPIFolder object is based on a path, such 
as "Public Folders/All Public Folders/Company/Sales".
    Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
    
    For Each olMail In Fldr.Items
    'MsgBox Date - 2
    'MsgBox Date
    'MsgBox DateValue(olMail.ReceivedTime)
    'Range("A3").Value = Date - 2
    'Range("A4").Value = DateValue(olMail.ReceivedTime)
    
    If Date - 2 < DateValue(olMail.ReceivedTime) Then
  ' MsgBox olMail.ReceivedTime
  '  MsgBox olMail.Subject
    lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    
    ActiveSheet.Range("A" & lr).Value = olMail.Subject
    ActiveSheet.Range("B" & lr).Value = olMail.Body
    ActiveSheet.Range("C" & lr).Value = olMail.Sender
    ActiveSheet.Range("d" & lr).Value = olMail.SenderName
    ActiveSheet.Range("e" & lr).Value = olMail.To
    ActiveSheet.Range("f" & lr).Value = olMail.CC
    ActiveSheet.Range("f" & lr).Value = olMail.BCC
    ActiveSheet.Range("g" & lr).Value = olMail.ReceivedTime
    
End If

   Next olMail

    Set Fldr = Nothing
    Set olNs = Nothing
    Set olApp = Nothing

End Sub


On Monday, May 18, 2015 at 2:15:38 PM UTC+5:30, Sundarvelan wrote:
>
> But I want Macro Excel File that will auto update all mail details in 
> excel periodically.
>
> Please help!!!
>
> Thanks
> N.Sundarvelan
> 9600160150
>
> On Mon, May 18, 2015 at 2:11 PM, Sundarvelan N <nsun...@gmail.com 
> <javascript:>> wrote:
>
>> Thanks Mandeep!!!
>>
>> Thanks
>> N.Sundarvelan
>> 9600160150
>>
>> On Mon, May 18, 2015 at 11:21 AM, Mandeep Baluja <rocke...@gmail.com 
>> <javascript:>> wrote:
>>
>>> Go to file option Click on open then export it to excel , you can export 
>>> any folder to a excel file. 
>>>
>>> Regards, 
>>> Mandeep Baluja 
>>>
>>>
>>>
>>>
>>> On Monday, May 18, 2015 at 10:47:24 AM UTC+5:30, Sundarvelan wrote:
>>>>
>>>> Dear Friends,
>>>>
>>>> Is there any possibilities copy, Subject, From Name with email Address, 
>>>> Body of the mail and attachements.
>>>>
>>>> with customized From Date - To Date
>>>>
>>>>
>>>> Thanks
>>>> N.Sundarvelan
>>>> 9600160150
>>>>  
>>>  -- 
>>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? 
>>> It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
>>> https://www.facebook.com/discussexcel
>>>  
>>> FORUM RULES
>>>  
>>> 1) Use concise, accurate thread titles. Poor thread titles, like Please 
>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice 
>>> will not get quick attention or may not be answered.
>>> 2) Don't post a question in the thread of another member.
>>> 3) Don't post questions regarding breaking or bypassing any security 
>>> measure.
>>> 4) Acknowledge the responses you receive, good or bad.
>>> 5) Jobs posting is not allowed.
>>> 6) Sharing copyrighted material and their links is not allowed.
>>>  
>>> NOTE : Don't ever post confidential data in a workbook. Forum owners and 
>>> members are not responsible for any loss.
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "MS EXCEL AND VBA MACROS" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to excel-macros...@googlegroups.com <javascript:>.
>>> To post to this group, send email to excel-...@googlegroups.com 
>>> <javascript:>.
>>> Visit this group at http://groups.google.com/group/excel-macros.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to