vb script to grab outlook inbox mail and append date sent to a file

I want to write a vb script to poll at an outlook inbox, open any unread mail, grab the date on there, and write that date and time value to a file.

The script will keep polling until it is killed. So that means it will need to keep appending to the output file one line of date and time for every incoming mail...

any help would be greatly appreciated!
jade03Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jade03Author Commented:
Ok, I think I figured out something...it works halfway now...I can grab mail from the inbox and grab specific info from that mail and send it to a file...problem is, I still can't seem to grab the date and time from that particular mail...apparently folderItem.Sent is not it...

any ideas?
jimbobmcgeeCommented:
The property you are looking for is folderItem.SentOn

HTH

J.
jimbobmcgeeCommented:
If you declare a reference to the Microsoft Scripting Runtime, in your project, you can access the FileSystemObject.

Now, declare two objects as Public, e.g.:

     Public objFSO as Scripting.FileSystemObject
     Public objTS as Scripting.TextStream

Since these values are public, they should be available to all procedures you write.  Now, you can set these up, initially, with:

     Set objFSO = CreateObject("Scripting.FileSystemObject")
     Set objTS = objFSO.CreateTextFile("x:\mypath\mylogfile.log", ForAppending, True)

Whenever you want to write to a file, use:

     objTS.WriteLine folderItem.SentOn

When its time to end your program, use

     objTS.Close

to close and save the file.

HTH

J.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jimbobmcgeeCommented:
Alternatively, you can do it the old-fashioned way:

Every time you want to write to the log file, you can use:

       Open "x:\mypath\mylogfile.log" For Append As #1
             Print #1, folderItem.SentOn
       Close #1

to open, write and save the file, each time you write to it.

If you can get it working, however, my previous suggestion should be less resource-intensive (not that it should matter too much)

J.
jade03Author Commented:
Great! Thanx, J! :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.