Outlook은 따로 처리하는 컴포넌트가 없고 win32를 통해 바로 Outlook의 데이터를 읽어야 하는것 같다.


win32를 사용하기 위한 python용 컴포넌트 설치

pip install pywin32

S:\WORK2>pip install pywin32

Collecting pywin32

  Downloading https://files.pythonhosted.org/packages/d4/2d/b927e61c4a2b0aaaab72c8cb97cf748c319c399d804293164b0c43380d5f/pywin32-223-cp36-cp36m-win32.whl (8.3MB)

    100% |████████████████████████████████| 8.3MB 3.7MB/s

Installing collected packages: pywin32

Successfully installed pywin32-223


python 샘플 코드

# Outlook의 Inbox에 들어있는 메일 정보 1건 읽어오기

import win32com.client


outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")

inbox = outlook.GetDefaultFolder(6)

messages = inbox.Items

#print(inbox.Items.Count)


message = messages.GetLast()

print(message.SenderEmailAddress)

print(message.SenderName)

print(message.SenderEmailType)

print(message.To)

print(message.CC)

print(message.ConversationID)

print(message.ConversationIndex)

print(message.ConversationTopic)

print(message.CreationTime)

print(message.ReceivedTime)

print(message.Subject)

print(message.Size)


[참고]

Folder type 설명

# Folder Type 6은 inbox를 의미한다. 

https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/oldefaultfolders-enumeration-outlook


Items Object 설명

https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/items-object-outlook

 

Mail Properties 설명

https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/mailitem-object-outlook



YOUR COMMENT IS THE CRITICAL SUCCESS FACTOR FOR THE QUALITY OF BLOG POST