
Reading Email with Windows Script Host script
I have worked out a script that connects to outlook and reads the
contents of your inbox. Run this script using cscript.exe and the
messages will output to the console window.
This is my first script that i have posted. If anyone sees an easier
way...please post. I'd love to be able to take the output and save it
as a csv file. Thats next on my agenda.
Thanks for all the suggestions.
Dim oOutlook
Dim oNamespace
Dim objInBox, objItem
Dim email, AllEmail, NewEmail
Set oOutlook = CreateObject("Outlook.Application")
Set oNamespace = oOutlook.GetNameSpace("Mapi")
Set objInBox = oNamespace.GetDefaultFolder(6)
AllEmail = 0
NewEmail = 0
For Each objItem in objInBox.Items
AllEmail = AllEmail + 1
If objItem.UnRead Then
NewEmail= NewEmail + 1
email = email & "From: " & objItem.SenderName & vbCrLf
email = email & "Subject: " & objItem.Subject & vbCrLf
email = email & "Body: " & vbCrLf & vbCrLf & objItem.Body & vbCrLf
email = email & "============================================" &
vbCrLf
email = email & "============================================" &
vbCrLf & vbCrLf
End If
Next
WScript.Echo "All E-mails: " & AllEmail & vbNewLine & "New E-mails: "
& NewEmail & vbNewLine & vbNewLine & email
Quote:
>I need to be able to read email messages into a console window and
>also be able to get the subject line and other message properties into
>variables. This is READING email NOT sending!!!
>Any ideas???
>-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
>http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
>-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----