Read mail's Subject

Maurizio

Well-known Member
Joined
Oct 15, 2002
Messages
691
Office Version
  1. 2007
Platform
  1. Windows
Hi all,
is it possible read, with vba, all "Subject" from my received mails (Outlook Express 6.0) on 05/05/2003 and report them on a sheets?

Tia.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
AFAIK, Outlook Express is not "programmable" because it doesn't provide an Automation interface. It would be possible with Outlook tough...
 
Upvote 0
Thanks Juan Pablo for your reply.

... and with Outlook?
 
Upvote 0
How about this ?

<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> 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>
    i = 1
    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> MItem <SPAN style="color:#00007F">In</SPAN> Inbox.Items
        <SPAN style="color:#00007F">If</SPAN> Int(MItem.ReceivedTime) = Int(DateSerial(2003, 5, 5)) <SPAN style="color:#00007F">Then</SPAN>
            i = i + 1
            Cells(i, 1) = MItem.Subject
        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
    <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">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
 
Upvote 0
in this formula, where can i point it to a specific folder in my inbox...let's call it 'x'.....?
 
Upvote 0
To do this for "X" then amend as follows...


<font face=Courier New><SPAN style="color:darkblue">Option</SPAN> <SPAN style="color:darkblue">Explicit</SPAN>

<SPAN style="color:green">'// JPG</SPAN>

<SPAN style="color:darkblue">Sub</SPAN> ReadFromOutlook()
<SPAN style="color:darkblue">Dim</SPAN> OutApp <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>    <SPAN style="color:green">'Outlook.Application</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> NmSpace <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>   <SPAN style="color:green">'Outlook.NameSpace</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> Inbox <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>     <SPAN style="color:green">'Outlook.MAPIFolder</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> MItem <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>     <SPAN style="color:green">'Outlook.MailItem</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> MySubFolder <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> i <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>

<SPAN style="color:darkblue">Set</SPAN> OutApp = CreateObject("Outlook.Application")
<SPAN style="color:darkblue">Set</SPAN> NmSpace = OutApp.GetNamespace("MAPI")
<SPAN style="color:darkblue">Set</SPAN> Inbox = NmSpace.GetDefaultFolder(6)  <SPAN style="color:green">'olFolderInbox</SPAN>
<SPAN style="color:darkblue">Set</SPAN> MySubFolder = Inbox.Folders("X") <SPAN style="color:green">' Note Case Sensitive!</SPAN>
i = 1

<SPAN style="color:green">'// In case of UNDELIVERABLES</SPAN>
<SPAN style="color:darkblue">On</SPAN> <SPAN style="color:darkblue">Error</SPAN> <SPAN style="color:darkblue">Resume</SPAN> <SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:green">'For Each MItem In Inbox.Items</SPAN>
<SPAN style="color:darkblue">For</SPAN> <SPAN style="color:darkblue">Each</SPAN> MItem <SPAN style="color:darkblue">In</SPAN> MySubFolder.Items
    <SPAN style="color:darkblue">If</SPAN> Int(MItem.ReceivedTime) = Int(DateSerial(2003, 5, 15)) <SPAN style="color:darkblue">Then</SPAN>
        <SPAN style="color:darkblue">If</SPAN> Err <SPAN style="color:darkblue">Then</SPAN> Err.Clear: <SPAN style="color:darkblue">GoTo</SPAN> N
        i = i + 1
        Cells(i, 1) = MItem.Subject
    <SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
N:  <SPAN style="color:darkblue">Next</SPAN> MItem

<SPAN style="color:darkblue">Set</SPAN> MItem = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">Set</SPAN> Inbox = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">Set</SPAN> NmSpace = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">Set</SPAN> OutApp = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">Set</SPAN> MySubFolder = <SPAN style="color:darkblue">Nothing</SPAN>

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>
</FONT>
 
Upvote 0
sorry about that. poor board etiquette on my part. Thank you all for the help that you all have provided.

It is not just the subject that I would like to pull, though, I want the From: field and the time received field to appear as well as the subject.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top