[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

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!
0
jade03
Asked:
jade03
  • 3
  • 2
1 Solution
 
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?
0
 
jimbobmcgeeCommented:
The property you are looking for is folderItem.SentOn

HTH

J.
0
 
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.
0
 
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.
0
 
jade03Author Commented:
Great! Thanx, J! :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now