@@ -279,7 +279,7 @@ def __init__(self, *, parent=None, con=None, **kwargs):
279279
280280 self .__attachments = MessageAttachments (parent = self , attachments = [])
281281 self .__attachments .add ({self ._cloud_data_key : cloud_data .get (cc ('attachments' ), [])})
282- self .has_attachments = cloud_data .get (cc ('hasAttachments' ), False )
282+ self .__has_attachments = cloud_data .get (cc ('hasAttachments' ), False )
283283 self .__subject = cloud_data .get (cc ('subject' ), '' )
284284 self .__body_preview = cloud_data .get (cc ('bodyPreview' ), '' )
285285 body = cloud_data .get (cc ('body' ), {})
@@ -290,12 +290,7 @@ def __init__(self, *, parent=None, con=None, **kwargs):
290290 self .__unique_body = unique_body .get (cc ('content' ), '' )
291291 self .unique_body_type = unique_body .get (cc ('contentType' ), 'HTML' ) # default to HTML for new messages
292292
293- if self .has_attachments is False and self .body_type .upper () == 'HTML' :
294- # test for inline attachments (Azure responds with hasAttachments=False when there are only inline attachments):
295- if any (img .get ('src' , '' ).startswith ('cid:' ) for img in self .get_body_soup ().find_all ('img' )):
296- self .has_attachments = True
297-
298- if self .has_attachments and download_attachments :
293+ if download_attachments and self .has_attachments :
299294 self .attachments .download_attachments ()
300295
301296 self .__sender = self ._recipient_from_cloud (
@@ -364,6 +359,18 @@ def is_read(self, value):
364359 self .__is_read = value
365360 self ._track_changes .add ('isRead' )
366361
362+ @property
363+ def has_attachments (self ):
364+ """ Check if the message contains attachments
365+
366+ :type: bool
367+ """
368+ if self .__has_attachments is False and self .body_type .upper () == 'HTML' :
369+ # test for inline attachments (Azure responds with hasAttachments=False when there are only inline attachments):
370+ if any (img .get ('src' , '' ).startswith ('cid:' ) for img in self .get_body_soup ().find_all ('img' )):
371+ self .__has_attachments = True
372+ return self .__has_attachments
373+
367374 @property
368375 def is_draft (self ):
369376 """ Check if the message is marked as draft
0 commit comments