How to extract date and time stamp from messsages

  • Thread starter Thread starter nitesh bansal
  • Start date Start date
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,
 
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:
 
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,
 
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:
 
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
 
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
 
Back
Top