Created
December 25, 2015 09:29
-
-
Save nasitra/6e5159128495b2139ef8 to your computer and use it in GitHub Desktop.
Collect mail subjects from Outlook in Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var outlook = WScript.CreateObject('Outlook.Application'); | |
var olFolderInbox = 6; | |
var nameSpace = outlook.GetNamespace('MAPI'); | |
var folder = nameSpace.GetDefaultFolder(olFolderInbox); | |
var isOpend = !!outlook.ActiveWindow; | |
if (!isOpend) { | |
folder.Display(); | |
outlook.ActiveWindow.WindowState = 1 | |
} | |
var subject = folder.Items(folder.Items.Count).Subject; | |
var box = folder.Items | |
var boxmail = box.GetFirst; | |
while (boxmail != null) { | |
WScript.Echo(boxmail.subject); | |
boxmail = box.GetNext; | |
} | |
if (!isOpend) | |
outlook.explorers.Item(outlook.explorers.Count).Close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment