How to extract date and time stamp from messsages

Status
Not open for further replies.
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,
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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

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,
 
N

nitesh bansal

On Aug 21, 9:45 am, "Michael Bauer " <m...@mvps.org
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.

> > Best regards
> Michael Bauer

> > > : <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,
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
It will work if you don't call the Display method as that doesn't return an

object.

Best regards

Michael Bauer

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


> On Aug 21, 9:45 am, "Michael Bauer " <m...@mvps.org
> 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.
>

>> > > Best regards
> > Michael Bauer
>

>> >> >> : <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,
 
N

nitesh bansal

On Aug 24, 10:09 pm, "Michael Bauer " <m...@mvps.org
wrote:
> It will work if you don't call the Display method as that doesn't return an
> object.

> > Best regards
> Michael Bauer

> > > : <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 " <m...@mvps.org
> > 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.

>
> >> > >> Best regards
> >> Michael Bauer

>
> >> > >> > >> : <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.
 
N

nitesh bansal

On Aug 25, 12:01 pm, nitesh bansal <niteshbansa...@gmail.com> wrote:
> On Aug 24, 10:09 pm, "Michael Bauer " <m...@mvps.org
> wrote:

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

>
> > > > Best regards
> > Michael Bauer

>
> > > > > > : <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 " <m...@mvps.org
> > > 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

>
> > >> > > >> > > >> : <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
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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

Am Tue, 25 Aug 2009 02:13:38 -0700 (PDT) schrieb nitesh bansal:


> On Aug 25, 12:01 pm, nitesh bansal <niteshbansa...@gmail.com> wrote:
> > On Aug 24, 10:09 pm, "Michael Bauer " <m...@mvps.org
>> wrote:
>

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


an
> >> object.

> >
> >> > >> Best regards
> >> Michael Bauer

> >
> >> >>> >>> : <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 " <m...@mvps.org
>>> > 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.

> >
> >> >> > >> >> Best regards
> >> >> Michael Bauer

> >
> >> >> >>> >> >>> >> : <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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Unable to extract text from an Outlook email message Using Outlook 2
S Macro to extract and modify links from emails Outlook VBA and Custom Forms 3
S Macro to extract email addresses of recipients in current drafted email and put into clipboard Outlook VBA and Custom Forms 2
C Macro to extract sender name & subject line of incoming emails to single txt file Outlook VBA and Custom Forms 3
N Extract Outlook emails to excel Outlook VBA and Custom Forms 2
M Extract all links from Outlook email, send to Excel Using Outlook 2
T Extract Data From Outlook Tasks Using Outlook 0
T Extract Data From Outlook Tasks Using Outlook 0
V extract users of a particular department Outlook VBA and Custom Forms 1
J Outlook 2013 Extract Flag Completed dates to Excel Macro Outlook VBA and Custom Forms 16
S How to extract mail items from multiple folders and shared mailboxes? Outlook VBA and Custom Forms 0
K Extract email address from body and auto-reply outlook Using Outlook 1
R Trying to extract information between two symbols from outlook subject Using Outlook 2
K Extract email to excel from a specific sender Outlook VBA and Custom Forms 3
O VBA to extract email (fields and body) to Excel Outlook VBA and Custom Forms 14
P Recover / Extract Rules from standalone PST file creating RWZ file Using Outlook 2
B Extract Dates for Appointment Item in Body of email Outlook VBA and Custom Forms 10
D Need to extract a line from a word attachment, and add it to the subject line Outlook VBA and Custom Forms 3
E Extract excel files from outlook Outlook VBA and Custom Forms 2
K extract certain text from an Outlook Email Message Outlook VBA and Custom Forms 2
D VBA Script to extract text matching specific criteria Outlook VBA and Custom Forms 1
M Extract text in existing message body for use in newmail items Using Outlook 17
M HELP--Extract Data from 2003 outlook transfer to excel spreadsheet Using Outlook 1
M VBA Code to extract data from an Outlook Form Using Outlook 0
M Extract attachments with a script Using Outlook 0
M HELP - Can't open outlook... How can I extract my Emails that I had in folders Using Outlook 3
H Extract emails from Outlokk 2007 email body Using Outlook 0
K Extract Global Address List Using Outlook 1
R Saving Outlook Email As Text File Extract Outlook VBA and Custom Forms 2
N Programming to extract automatically extract attachments Outlook VBA and Custom Forms 3
S How to extract outlook calendar data. Outlook VBA and Custom Forms 3
? outlook attachment Extract File ??? Outlook VBA and Custom Forms 1
V Extract Subject,Sent From, Message from mailbox to Excel Outlook VBA and Custom Forms 5
S Automatically extract attachments? Outlook VBA and Custom Forms 1
I How to extract email addresses from TO or CC line of a particular email Outlook VBA and Custom Forms 2
S Archiving and Likely Modified Date Problem Using Outlook 3
A VBA Script - Print Date between first email in Category X and last email in Category Y Outlook VBA and Custom Forms 3
S Outlook 2016 Arrange tasks by date, additional custom sorting, but still use friendly terms like Today, Tomorrow, This week? Using Outlook 1
L Macro to add Date & Time etc to "drag to save" e-mails Outlook VBA and Custom Forms 8
S save attachment with date & time mentioned inside the file Outlook VBA and Custom Forms 0
witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
C Outlook with Office365 - search across account, by date rate, in multiple folders - how? Using Outlook 2
M Sorting by Day in Date Column Advanced Filter BCM (Business Contact Manager) 1
V Date and/or time error in Outlook Form Outlook VBA and Custom Forms 0
S Body text of Email from invite date/time Outlook VBA and Custom Forms 7
V 10 Years calenders -single date together Exchange Server Administration 8
O Export Outlook calendar appointments by filters and date range Outlook VBA and Custom Forms 1
D Add date next to day name in Outlook Today calendar view Using Outlook 1
X If you change expiration date of repeated task it dupplicates Using Outlook 1
D Archive by receive date not working Using Outlook 2

Similar threads

Top