Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pathlib import not working
#1
This is my first attempted script so it is of course not working.

I am trying to open outlook, find an email, and download the attachment

The first line of the tut I am looking at says I need to import path from pathlib and win32com.client.
I get an indentation Error for line 1 the pathlib path import. It is supposed to be a core python module and not need installing like pywin32 so I do not know what it wants.

from pathlib import path
import win32com.client


output_dir =path.cwd() / "outbut"
output_dir.mkdir(parents=true, exist_ok=true)

outlook = win32com.client.dispatch("outlook.application").getnamespace("MAPI")

inbox =outlook.getfaultfolder(6)

messages = inbox.items

for message in messages:
    subject = Punch.report
    body = Message.body
    attachments = message.Attachments

for attachment in attachments:
    attachment.SaveAsFile(Target_folder / str(Attachment))

Attached Files

.py   main.py (Size: 494 bytes / Downloads: 145)
Reply


Messages In This Thread
Pathlib import not working - by chriswrcg - May-29-2022, 01:04 PM
RE: Pathlib import not working - by Gribouillis - May-29-2022, 01:08 PM
RE: Pathlib import not working - by chriswrcg - May-29-2022, 01:32 PM
RE: Pathlib import not working - by chriswrcg - May-29-2022, 02:12 PM
RE: Pathlib import not working - by Gribouillis - May-29-2022, 04:24 PM
RE: Pathlib import not working - by snippsat - May-29-2022, 04:44 PM
RE: Pathlib import not working - by chriswrcg - May-29-2022, 05:25 PM
RE: Pathlib import not working - by snippsat - May-29-2022, 06:01 PM
RE: Pathlib import not working - by chriswrcg - May-29-2022, 06:07 PM
RE: Pathlib import not working - by snippsat - May-29-2022, 07:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  deleting an empty Dir, using pathlib.Path tester_V 9 5,936 Jul-01-2021, 01:53 PM
Last Post: Gribouillis
  Trying to pathlib instead of os.path tester_V 4 2,538 Jun-22-2021, 04:15 AM
Last Post: tester_V
  pathlib destpath.exists() true even file does not exist NaN 9 4,748 Dec-01-2020, 12:43 PM
Last Post: NaN
  Question about if with () or without () / pathlib Tecuma 3 2,252 Apr-02-2020, 10:02 AM
Last Post: Tecuma
  How to keep a loop containing a web import working in python executable? coder1384 3 2,910 Feb-22-2020, 06:49 PM
Last Post: snippsat
  import logging not working segerhult 3 13,285 Feb-07-2019, 05:31 PM
Last Post: buran
  CSV import is not working gehrenfeld 7 4,296 Dec-12-2018, 12:26 PM
Last Post: gehrenfeld
  pathlib hanging bluefrog 2 3,165 Sep-25-2018, 12:59 PM
Last Post: volcano63
  pathlib: resolving a path that does not exist Skaperen 6 5,581 Sep-08-2018, 12:25 AM
Last Post: Skaperen
  makin hardlinks with pathlib.Path Skaperen 2 5,276 Sep-06-2018, 07:53 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020