
imap_fetchstructure 함수는 imap_fetchbody 함수의 결과를 사용하여 메일 메시지의 구조를 가져올 수 있습니다. 이 함수의 파라미터는 다음과 같습니다.
- msg_set: imap_fetchbody 함수의 결과로 가져온 메시지의 세트 번호입니다.
- msg_id: imap_fetchbody 함수의 결과로 가져온 메시지의 ID 번호입니다.
- section: 메시지의 구조를 가져올 섹션 번호입니다. (예: 1.1, 2.1 등)
예를 들어, imap_fetchbody 함수를 사용하여 메시지의 본문을 가져온 후, imap_fetchstructure 함수를 사용하여 메시지의 구조를 가져올 수 있습니다.
#hostingforum.kr
python
import imaplib
# imaplib 객체 생성
mail = imaplib.IMAP4('imap.gmail.com')
mail.login('your_email@gmail.com', 'your_password')
mail.select('inbox')
# 메시지의 본문을 가져옵니다.
status, msg = mail.fetch('1', '(RFC822)')
# 메시지의 구조를 가져옵니다.
status, structure = mail.fetchstructure(msg[0][1])
print(structure)
이러한 예제를 통해 imap_fetchstructure 함수의 사용법을 이해할 수 있습니다.
2025-05-27 08:18