If x.Attachments
doesn't exists then it doesn't create attachment
but you try to use it.
If you want to create sum
only when there is attachment then you should change indentations
if x.Attachments:
for f in x.Attachments:
attachment = f.FileName
sum = [subject, sender, senderEmail, attachment]
#list.extend(sum)
list.append(sum)
If you want to create also when there is no attachment
then you need else
Eventually you can use None
for attachment
and it will be easier to work with list which have the same number of items.
if x.Attachments:
for f in x.Attachments:
attachment = f.FileName
sum = [subject, sender, senderEmail, attachment]
#list.extend(sum)
list.append(sum)
else:
sum = [subject, sender, senderEmail, None]
#list.extend(sum)
list.append(sum)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…