0

I'm learning python still, and I want to open a file...I found os.startfile, but this creates a new window every time I want to open a file. How do I hide this window?

I'm sure there is another way instead of os.startfile that actually does this...any ideas?

Also, I'm trying to download one of the attachments in this weird format, any ideas? The file is originally a msg file.

Thanks! :D

arthur6523
  • 115
  • 1
  • 3
  • 7
  • what do you want to do exactly? open Outlook? open messages? read them? – Jean-François Fabre May 04 '17 at 19:21
  • ideally, it is to go through this folder with a lot of msg files. save a pdf from each of those files. – arthur6523 May 04 '17 at 19:23
  • 1
    This method is almost the same as just double-clicking on a thing. It is not the same as bringing a file into python, and then treating it as an object, and doing stuff to it. – TehTris May 04 '17 at 19:23
  • maybe it would help: http://stackoverflow.com/questions/22399835/how-to-save-attachment-from-outlook-using-win32com-client-in-python – Jean-François Fabre May 04 '17 at 19:24
  • Yeah, super true. I'm super stuck because I have no experience dealing with this msg file. – arthur6523 May 04 '17 at 19:25
  • I've looked at multiple solutions like that Jean. I understand Python going into Outlook and manipulating it from there...but I'm stuck with msg files in a folder, without the original location of the email. – arthur6523 May 04 '17 at 19:26
  • here it opens .msg files from disk (using python & outlook): http://stackoverflow.com/questions/37269165/python-open-outlook-email-msg-file-in-read-write-mode – Jean-François Fabre May 04 '17 at 19:47
  • Tried this one too :/ doesn't have any feature to allow me to download the attachments – arthur6523 May 04 '17 at 19:52
  • When all else fails use `win32com` to access the outlook folder/namespace that contains the emails, iterate over the email objects and their respective `.Attachments` collections. Each item in `Attachments` has a [`.SaveAsFile`](https://msdn.microsoft.com/en-us/library/office/ff869359.aspx) method which you can use to save the attachment to disk. – David Zemens May 05 '17 at 17:03

0 Answers0