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,
 
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,
 
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,
 
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,
 
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.
 
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
 
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
M Extract "Date sent" from emails (saved to folder using drag and drop) Outlook VBA and Custom Forms 1
C Wishlist Extract or scan new email addresses from out of office replies. Leads from OOO replies Using Outlook 1
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
T vba extract data from msg file as attachment file of mail message Outlook VBA and Custom Forms 1
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
F Outlook 365 Group INBOX by date but not by date and time Using Outlook 1
S Displaying Date Value In Formula Outlook VBA and Custom Forms 6
CWM550 Wrong Date Using Outlook 4
C Outlook 365 Copy/Save Emails in Folder Outside Outlook to Show Date Sender Recipient Subject in Header Using Outlook 0
R unable to filter tasks when start date is on or before today Using Outlook 3
S Combination Field (Date Format) Outlook VBA and Custom Forms 0
U How can the Received date be edited? Using Outlook 0
D This folder up to date vs all folders up to date Using Outlook 1
S Outlook Macro for [Date][Subject] Using Outlook 1
N Save emails within a certain date range to network drive Outlook VBA and Custom Forms 0
kburrows Reset Date to Keep Tasks from Archiving Using Outlook 9

Similar threads

Back
Top