How to extract date and time stamp from messsages

N

nitesh bansal

Hi

is it possible to write a macro that extracts the date and time stamp
of an incoming message coming in the inbox folder and save those
stamps in an excel sheet in separate columns with another column
adding the subject of the mail, and then finally move such message to
a specific folder.

Thanks in advance,
 
M

Michael Bauer [MVP - Outlook]

Use the ItemAdd or NewMailEx events of the Inbox. If you want to get the
received time, read the ReceivedTime property.

Add a reference to the Excel library to your VBA project. Use the
Workbooks.Open function to get a workbook, then Sheets and Range to work
with sheets and cells. See the object browser (f2) for more details of
what's exposed by the object model. And press f1 for help.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Thu, 20 Aug 2009 22:32:02 -0700 (PDT) schrieb nitesh bansal:
 
N

nitesh bansal

Use the ItemAdd or NewMailEx events of the Inbox. If you want to get the
received time, read the ReceivedTime property.

Add a reference to the Excel library to your VBA project. Use the
Workbooks.Open function to get a workbook, then Sheets and Range to work
with sheets and cells. See the object browser (f2) for more details of
what's exposed by the object model. And press f1 for help.

--
Best regards
Michael Bauer - MVP Outlook

  : Outlook Categories? Category Manager Is Your Tool
  : VBOffice Reporter for Data Analysis & Reporting
  : <http://www.vboffice.net/product.html?pub=6〈=en>

Am Thu, 20 Aug 2009 22:32:02 -0700 (PDT) schrieb nitesh bansal:

Hi

I tried the following code

Sub TimeStampDigger()

Dim i%, myItem As Outlook.MailItem

Set myItem = Application.Session.GetDefaultFolder
(olFolderInbox).Items(1).Display

myTime = myItem.ReceivedTime

End Sub

The 2nd line of the code gives an error. I can't figure out how to set
mailItem as Item or Item as mailItem. I am completely confused about
this.
Kindly help.

Thanks,
 
M

Michael Bauer [MVP - Outlook]

It will work if you don't call the Display method as that doesn't return an
object.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Mon, 24 Aug 2009 01:33:12 -0700 (PDT) schrieb nitesh bansal:
 
N

nitesh bansal

It will work if you don't call the Display method as that doesn't return an
object.
  : Outlook Categories? Category Manager Is Your Tool
  : VBOffice Reporter for Data Analysis & Reporting
  : <http://www.vboffice.net/product.html?pub=6〈=en>
Am Mon, 24 Aug 2009 01:33:12 -0700 (PDT) schrieb nitesh bansal:
On Aug 21, 9:45 am, "Michael Bauer [MVP - Outlook]" <[email protected]>
wrote:
Use the ItemAdd or NewMailEx events of the Inbox. If you want to getthe
received time, read the ReceivedTime property.
Add a reference to the Excel library to your VBA project. Use the
Workbooks.Open function to get a workbook, then Sheets and Range to work
with sheets and cells. See the object browser (f2) for more details of
what's exposed by the object model. And press f1 for help.
--
Best regards
Michael Bauer - MVP Outlook
  : Outlook Categories? Category Manager Is Your Tool
  : VBOffice Reporter for Data Analysis & Reporting
  : <http://www.vboffice.net/product.html?pub=6〈=en>
Am Thu, 20 Aug 2009 22:32:02 -0700 (PDT) schrieb nitesh bansal:
Hi
is it possible to write a macro that extracts the date and time stamp
of an incoming message coming in the inbox folder and save those
stamps in an excel sheet in separate columns with another column
adding the subject of the mail, and then finally move such message to
a specific folder.
Thanks in advance,
Hi
I tried the following code
Sub TimeStampDigger()
    Dim i%, myItem As Outlook.MailItem
    Set myItem = Application.Session.GetDefaultFolder
(olFolderInbox).Items(1).Display
    myTime = myItem.ReceivedTime
End Sub
The 2nd line of the code gives an error. I can't figure out how to set
mailItem as Item or Item as mailItem. I am completely confused about
this.
Kindly help.
Thanks,

Hi

It worked perfectly.

Thanks.

But I have one more question.

How do I find using VBA whether an email message has an attachment or
not?

Thanks
 
M

Michael Bauer [MVP - Outlook]

See the item's Attachments collection. Very helpful for what properties are
exposed by what objects is the object browser: press f2, then switch from
<All Libraries> to Outlook.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Tue, 25 Aug 2009 02:13:38 -0700 (PDT) schrieb nitesh bansal:
It will work if you don't call the Display method as that doesn't return an
object.
  : Outlook Categories? Category Manager Is Your Tool
  : VBOffice Reporter for Data Analysis & Reporting
  : <http://www.vboffice.net/product.html?pub=6〈=en>
Am Mon, 24 Aug 2009 01:33:12 -0700 (PDT) schrieb nitesh bansal:
On Aug 21, 9:45 am, "Michael Bauer [MVP - Outlook]" <[email protected]>
wrote:
Use the ItemAdd or NewMailEx events of the Inbox. If you want to get the
received time, read the ReceivedTime property.
Add a reference to the Excel library to your VBA project. Use the
Workbooks.Open function to get a workbook, then Sheets and Range to work
with sheets and cells. See the object browser (f2) for more details of
what's exposed by the object model. And press f1 for help.
  : Outlook Categories? Category Manager Is Your Tool
  : VBOffice Reporter for Data Analysis & Reporting
  : <http://www.vboffice.net/product.html?pub=6〈=en>
Am Thu, 20 Aug 2009 22:32:02 -0700 (PDT) schrieb nitesh bansal:

is it possible to write a macro that extracts the date and time stamp
of an incoming message coming in the inbox folder and save those
stamps in an excel sheet in separate columns with another column
adding the subject of the mail, and then finally move such message to
a specific folder.
Thanks in advance,

I tried the following code
Sub TimeStampDigger()
    Dim i%, myItem As Outlook.MailItem
    Set myItem = Application.Session.GetDefaultFolder
(olFolderInbox).Items(1).Display
    myTime = myItem.ReceivedTime
The 2nd line of the code gives an error. I can't figure out how to set
mailItem as Item or Item as mailItem. I am completely confused about
this.
Kindly help.

Hi

It worked perfectly.

Thanks.

But I have one more question.

How do I find using VBA whether an email message has an attachment or
not?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top