Skip to content

Instantly share code, notes, and snippets.

@nasitra
Created December 25, 2015 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nasitra/6e5159128495b2139ef8 to your computer and use it in GitHub Desktop.
Save nasitra/6e5159128495b2139ef8 to your computer and use it in GitHub Desktop.
Collect mail subjects from Outlook in Windows
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