Skip to content

Instantly share code, notes, and snippets.

@Shobin23
Created July 31, 2018 08: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 Shobin23/6d2af8b0a65328fafdd1621622933f73 to your computer and use it in GitHub Desktop.
Save Shobin23/6d2af8b0a65328fafdd1621622933f73 to your computer and use it in GitHub Desktop.
For vs While
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case,
# the inbox. You can change that number to reference
# any other folder
messages = inbox.Items
message = messages.GetFirst()
rec_time = message.CreationTime
body_content = message.body
subj_line = message.subject
#--------- This works-----------------
#while message:
# print(message.subject, message.CreationTime)
# message = messages.GetNext()
#---------This doesnt ----------------
#for mess in range(message):
# print(mess.subject, mess.CreationTime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment