Ivan beat me to it, but I had the reply ready, so here it is:
Well, you changed the code a lot (Well, not a lot :wink: )... for example:
Code:
If Int(MItem.ReceivedTime) <= Month() Then
This line is producing an error. What are you trying to do here ?
and this one
Code:
Cells(i, 0) = MItem.Subject
That's also producing an error. I didn't use a , 0 in the code I gave... should start with a 1 (As in the first column)
Anyway, I think that what you're trying to do is get the mails from the subfolder Bellsouth, that have arrived this month, right ?
Oh, I had an error too
, there is no From property... I should have checked that before... sorry.
<font face=Courier New>
<SPAN style="color:#00007F">Sub</SPAN> ReadFromOutlook()
<SPAN style="color:#00007F">Dim</SPAN> OutApp <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN> <SPAN style="color:#007F00">'Outlook.Application</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> NmSpace <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN> <SPAN style="color:#007F00">'Outlook.NameSpace</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> Inbox <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN> <SPAN style="color:#007F00">'Outlook.MAPIFolder</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> MItem <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN> <SPAN style="color:#007F00">'Outlook.MailItem</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> MySubFolder <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
<SPAN style="color:#00007F">Set</SPAN> OutApp = CreateObject("Outlook.Application")
<SPAN style="color:#00007F">Set</SPAN> NmSpace = OutApp.GetNamespace("MAPI")
<SPAN style="color:#00007F">Set</SPAN> Inbox = NmSpace.GetDefaultFolder(6) <SPAN style="color:#007F00">'olFolderInbox</SPAN>
<SPAN style="color:#00007F">Set</SPAN> MySubFolder = Inbox.Folders("Bellsouth") <SPAN style="color:#007F00">' Note Case Sensitive!</SPAN>
i = 1
<SPAN style="color:#007F00">'// In case of UNDELIVERABLES</SPAN>
<SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN>
<SPAN style="color:#007F00">'For Each MItem In Inbox.Items</SPAN>
<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> MItem <SPAN style="color:#00007F">In</SPAN> MySubFolder.Items
<SPAN style="color:#00007F">If</SPAN> Month(MItem.ReceivedTime) >= Month(Date) And _
Year(MItem.ReceivedTime) >= Year(Date) <SPAN style="color:#00007F">Then</SPAN>
<SPAN style="color:#00007F">If</SPAN> Err <SPAN style="color:#00007F">Then</SPAN> Err.Clear: <SPAN style="color:#00007F">GoTo</SPAN> N
i = i + 1
Cells(i, 1) = MItem.Subject
<SPAN style="color:#007F00">'Cells(i, 2) = MItem.From</SPAN>
Cells(i, 2) = MItem.SenderName
Cells(i, 3) = MItem.ReceivedTime
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
N: <SPAN style="color:#00007F">Next</SPAN> MItem
<SPAN style="color:#00007F">Set</SPAN> MItem = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">Set</SPAN> Inbox = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">Set</SPAN> NmSpace = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">Set</SPAN> OutApp = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">Set</SPAN> MySubFolder = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>