Are you using relative paths? Do any of the paths in the log file start with, say, C:\?
It’s always better to be explicit and use absolute paths.
It might be that your script is making paths relative to wherever the current working directory happens to be, but when you tell Outlook to save a file with a relative path, it’s trying to save relative to its default directory.
For example, suppose your current working directory is C:\MyStuff. You make a relative path MyFolder\MyFile and, as far as you’re concerned, the full path is C:\MyStuff\MyFolder\MyFile, but Outlook’s default directory is C:\OutlookStuff, so when you tell it to save as MyFolder\MyFile, it tries to save as C:\OutlookStuff\MyFolder\MyFile, but C:\OutlookStuff\MyFolder doesn’t exist.
actually it works with absolute path and i tried writing simpler one it dis download the attchamnets but the thing here is i wanted everything to be dynamiclly generated not hard codes even if a user used this it can run smoothly thats my goal to adapt without hardcoding path
i feel i get what you mean yet it make since somehow though i am not quit understanding but can you please explain more or with another example and how would that be resolved ?
That is a desired folder name but NOT a path. You need an actual valid directory path.
Using an analogy, you’re giving them your house number only but not the state, city, and zip code. You need all elements in order for someone to send you a letter.
I understand now but i want to understand something is that only regarding saving the attachment it self right ? cuz the main folder and sub folders are created fine even the subfolders of subfolders with names of the attachments are created so we only talk about attachments alone right ?
and what do you recommend other than absolute path i want to learn make things dynamic adapting any position
Look at your computer. There must be hundreds of folders (thousands). You’re the developer. You define the special directory where you want these modules/files to be saved to. It can’t be random.
You can try something like this where the user is prompted for a directory to save the file to:
from tkinter.filedialog import askdirectory
path = askdirectory(title = 'Select Folder')
base_path = Path(path)
print(base_path) # Printing for test purposes only