PyOutlook: AttributeError: объект 'str' не имеет атрибута 'api_representation'Python

Программы на Python
Ответить
Anonymous
 PyOutlook: AttributeError: объект 'str' не имеет атрибута 'api_representation'

Сообщение Anonymous »

pyOutlook 5.0.0;

Python 3.12.3
Код на основе документации pyOutlook

Код: Выделить всё

from pyOutlook import OutlookAccount, Contact

token = "..."

account = OutlookAccount(token)
account.messages.send(
subject='Hey there',
body="I'm sending an email through Python.
Best,
Me",
to=['me@somewhere.com']
)
Полное сообщение об ошибке:

Код: Выделить всё

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File c:\...\pyOutlook-test.py:6
3 token = "..."
5 account = OutlookAccount(token)
----> 6 account.messages.send(
7     subject='Hey there',
8     body="I'm sending an email through Python.
Best,
Me",
9     to=['me@somewhere.com']
10 )

File c:\...\anaconda3\Lib\site-packages\pyOutlook\services\message.py:174, in MessageService.send(self, subject, body, to, cc, bcc, attachments)
157 def send(self, subject: str, body: str, to: list[Contact], cc: list[Contact] | None = None,
158          bcc: list[Contact] | None = None, attachments: list['Attachment'] | None = None) -> None:
159     '''Sends a message.
160
161     Args:
(...)
166         bcc: The list of BCC recipients
167     '''
168     payload: dict[str, object] = {
169         'subject': subject,
170         'body': {
171             'contentType': 'HTML',
172             'content': body
...
175     }
176     if cc:
177         payload['ccRecipients'] = [contact.api_representation() for contact in cc]

AttributeError: 'str' object has no attribute 'api_representation'
Я также попробовал ...to=[Contact('me@somewhere.com', name='myself')]
с той же ошибкой.

Что мне не хватает?

Подробнее здесь: https://stackoverflow.com/questions/798 ... esentation
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»