Aspose.email.for.python won't install

Trying to use: Aspose.Email_for_Python_via_NET-24.5-py3-none-win_amd64
in IneliJ PyCharm. It shows it as not installed, but pip list shows that it is:
Aspose.Email-for-Python-via-NET 24.5
Trying to install via PyCharm, fails: (Python Python 3.12.3)

Error: … 24.5 Requires-Python <3.12,>=3.5
ERROR: Could not find a version that satisfies the requirement Aspose.Email-for-Python-via-NET (from versions: none)
ERROR: No matching distribution found for Aspose.Email-for-Python-via-NET

Hello @guthrie ,

The issue you’re facing is due to a compatibility problem with the version of Python you’re using. Since you’re using Python 3.12.3, this package is not compatible with it.
Requires: Python <3.12 or >=3.5

Thank you.
I suppose I should have understood this from the error message!!
This is the current version of Python, is there a newer version of ASpose, or do I need to get an older version of Python?

@guthrie ,

You need an older version of Python.

Thanks! got it.
now it does resolve aspose.email, but says the sample code from
(Aspose.Email-for-Python-via-NET · PyPI)
fails; aspose.email.storage - not found
although that code is in the examples on github.
“from aspose.email.storage.pst import *”.

@guthrie,

This issue cannot be reproduced on our side.

Please open a Windows command prompt, enter the following commands, and report the command output.

mkdir test
cd test
python --version
python install venv
python -m venv env
call env\Scripts\activate.bat
pip uninstall Aspose.Email_for_Python_via_NET
pip install Aspose.Email_for_Python_via_NET

Then create in this directory file test.py with the following content:

####
from aspose.email import *
from aspose.email.storage.pst import *

with MailMessage("from@aaa.bb", "to@aaa.bb") as eml:
eml.subject = "test subject"
print(eml.subject)
eml.save("test.msg")
assert("Aspose.Email Evaluation" in eml.subject)

print("OK")
###

and execute this script:

python test.py
PowerShell 7.4.2
PS C:\Users\guthr\Desktop> python --version
Python 3.11.9
PS C:\Users\guthr\Desktop>
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Users\guthr\Desktop> cd test
PS C:\Users\guthr\Desktop\test> python install venv
E:\Plang\Python\Python311\python.exe: can't open file 'C:\\Users\\guthr\\Desktop\\test\\install': [Errno 2] No such file or directory
PS C:\Users\guthr\Desktop\test>

Sorry, there seems to be a mistake in the command, it should be python pip install venv.

PowerShell 7.4.2
PS C:\Users\guthr\Desktop> cd test
PS C:\Users\guthr\Desktop\test> python --version
Python 3.11.9
PS C:\Users\guthr\Desktop\test> python pip install venv
E:\Plang\Python\Python311\python.exe: can't open file 'C:\\Users\\guthr\\Desktop\\test\\pip': [Errno 2] No such file or directory
PS C:\Users\guthr\Desktop\test> pip install venv
ERROR: Could not find a version that satisfies the requirement venv (from versions: none)
ERROR: No matching distribution found for venv
PS C:\Users\guthr\Desktop\test>

Hello @guthrie,

we’ll look into it, and get back to you later.

Thank you.

I needed to install virtualenv first, then your test works - will now try my program again!
Thanks…
pip install virtualenv

@guthrie ,

Good! Thank you for the feedback.

I then tried to run some simple examples from your online repository, first was just to open a pst file but it failed.
Not sure what I am doing wrong.

PS C:\Users\guthr\Desktop\test> python --version
Python 3.11.9
PS C:\Users\guthr\Desktop\test> pip list | select-string aspose.email
Aspose.Email-for-Python-via-NET 24.6

> 
> PS C:\Users\guthr\Desktop\test> python pyReadOst.py
> File Format of OST: 1
> Traceback (most recent call last):
>   File "C:\Users\guthr\Desktop\test\pyReadOst.py", line 20, in <module>
>     folderInfoCollection = personalStorage.root_folder.get_sub_folders()
>                            ^^^^^^^^^^^^^^^
> NameError: name 'personalStorage' is not defined. Did you mean: 'PersonalStorage'?
> PS C:\Users\guthr\Desktop\test>

Program was:

from aspose.email.storage.pst import *

Data = ‘H:/guthrie-email/’
File = ‘guthrie@miu.edu.ost’

pst = PersonalStorage.from_file(Data + File)

Get the format of the file

print("File Format of OST: " + str(pst.format))

Hello @guthrie,

Sorry, but the output you provided does not match the code sample you referenced.

Anyway, here is the code that works:

import aspose.email as ae

personalStorage = ae.storage.pst.PersonalStorage.from_file("source.ost")

folderInfoCollection = personalStorage.root_folder.get_sub_folders()

for folderInfo in folderInfoCollection:
  print("Folder: " + folderInfo.display_name)
  print("Total Items: " + str(folderInfo.content_count))
  print("Total Unread Items: " + str(folderInfo.content_unread_count))
  print("----------------------")

Thank you, I’ll try that.
Many thanks for the help.

But The file at:

is this (below), so I’m not sure what I got wrong!
Aspose-ReadingOSTFiles.py.png (24.9 KB)


from aspose.email.storage.pst import *

def run():
dataDir = “Data/”
#ExStart: ReadingOSTFiles
pst = PersonalStorage.from_file(dataDir + “PersonalStorageFile.ost”)

## Get the format of the file
print("File Format of OST: " + str(pst.format))
#ExEnd: ReadingOSTFiles

if name == ‘main’:
run()

Hello @guthrie ,

The sample you are referencing works well on our side.

P.S. You provide an output where the error occurs on the line folderInfoCollection = personalStorage.root_folder.get_sub_folders(). But there is no such line in the code sample you are referring to.