PST 비밀번호 보호 속성 작업
Contents
[
Hide
]
Microsoft Outlook은 사용자가 PST 파일에 암호를 설정하여 접근을 제한할 수 있도록 합니다. Aspose.Email는 PST 파일의 암호 보호 여부를 감지할 수 있습니다.
이 문서는 다음 항목을 다룹니다:
- PST 파일 암호 보호 확인
- 암호 보호된 PST 파일 읽기
- 암호 보호된 PST에서 암호 검증
- PST 파일에서 암호 추가/변경/제거
PST 파일 암호 보호 확인
PST 파일이 암호로 보호되어 있는지 확인하려면, 클래스의 is_password_protected 메서드를 사용합니다. MessageStore 클래스는 아래 코드 샘플에 표시된 바와 같습니다:
import aspose.email as ae
pst = ae.storage.pst.PersonalStorage.from_file("my.pst")
print(f"The storage is password protected - {pst.store.is_password_protected}")
암호 보호된 PST 파일 읽기
암호로 보호된 파일도 일반 PST 파일처럼 읽을 수 있습니다. 다음 코드 스니펫은 각 개별 메시지에 접근하고 추가 처리할 수 있게 해줍니다:
import aspose.email as ae
pst = ae.storage.pst.PersonalStorage.from_file("my.pst")
for folder in pst.root_folder.get_sub_folders():
for msg in folder.enumerate_messages():
# do something
PST 비밀번호 검증
PST 파일의 비밀번호가 유효한지 확인하려면, Aspose.Email는 클래스의 is_password_valid(password) 메서드를 제공합니다. MessageStore 클래스입니다. 문자열 형식의 비밀번호를 매개변수로 받아 비밀번호가 올바르면 True, 그렇지 않으면 False를 반환합니다.
다음 코드 스니펫은 is_password_valid(password) 메서드 사용 예시를 보여줍니다:
import aspose.email as ae
pst = ae.storage.pst.PersonalStorage.from_file("my.pst")
print(f"Password is valid - {pst.store.is_password_valid('Password1')}")
PST 암호 추가, 변경 또는 제거
클래스의 change_password(password) 메서드 MessageStore 클래스는 PST 파일의 암호를 조작하는 데 사용됩니다. 다음 코드 샘플은 암호를 추가, 변경 또는 제거하는 방법을 보여줍니다:
import aspose.email as ae
pst = ae.storage.pst.PersonalStorage.create("SetPasswordOnPST_out.pst", ae.storage.pst.FileFormatVersion.UNICODE)
# Add or change the password
password = "Password1"
pst.store.change_password(password)
# Remove the password
pst.store.change_password(None)