Python Forum
Trying to determine attachment file type before saving off..
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to determine attachment file type before saving off..
#2
Found a solution that seems to work and do the job..

    # THIS ENSURES THAT THE EMAIL HAS AT LEAST 2 ATTACHMENTS BEFORE IT TRIES TO DOWNLOAD FILES THAT DONT EXIST
    # NEED TO FIND A WAY TO ONLY CARE IF THE ATTACHMENTS ARE CSV FILES AND NOTHING ELSE.
    if attachments.count >= 2:

        for att in attachments:
            p = Path(str(att).lower())
            newName = "{0}_{1}{2}".format(p.stem,dtappend,p.suffix)
            if p.suffix == ".csv":
                att.SaveASFile("F:\attachments"+ '\\' + newName)   
Reply


Messages In This Thread
RE: Trying to determine attachment file type before saving off.. - by cubangt - Feb-23-2022, 07:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to download TLS Report attachment blason16 6 626 Feb-26-2024, 07:36 AM
Last Post: Pedroski55
  How does sqlite3 module determine value type mirlos 2 1,002 Dec-12-2023, 09:37 AM
Last Post: mirlos
  Extract PDF Attachment from Gmail jstaffon 0 617 Sep-10-2023, 01:55 PM
Last Post: jstaffon
  determine parameter type in definition function akbarza 1 630 Aug-24-2023, 01:46 PM
Last Post: deanhystad
  Saving the times a script is run to a file or ... 3Pinter 7 1,515 Oct-19-2022, 05:38 PM
Last Post: 3Pinter
  Code Assistance needed in saving the file MithunT 0 850 Oct-09-2022, 03:50 PM
Last Post: MithunT
  Saving the print result in a text file Calli 8 1,935 Sep-25-2022, 06:38 PM
Last Post: snippsat
  I get attachment paperclip on email without any attachments monika_v 5 2,082 Mar-19-2022, 10:20 PM
Last Post: cosmarchy
  Showing and saving the output of a python file run through bash Rim 3 2,556 Oct-06-2021, 10:48 AM
Last Post: gerpark
  File type (mode) rayleiter 5 2,215 Aug-29-2021, 07:46 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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