I'm using exchangelib and works well but when I'm trying to export item information such as:
data= ("Inbox", item.datetime_received, item.sender, item.subject)
When I use print all items are displayed as expected, each email in new line:
Inbox 2019-10-15, jack, New email information
Inbox 2019-10-16, tom, Hello
Inbox 2019-10-17, anna, Test email
When I'm trying to write this to CSV using code below:
with open("C:/mail_export.csv",'w',newline='\n',encoding="utf-8") as f:
for item in inbox_folder.all().order_by('-datetime_received'):
data=("Inbox", item.datetime_received, item.sender, item.subject)
f.write(str(data))
I got all information in one long line and I can't save this so each item is starting from new line. Now looks like this:
Inbox 2019-10-15, jack, New email information Inbox 2019-10-16, tom, Hello Inbox 2019-10-17, anna, Test email
What I'm doing wrong ? How to write this the same way is displaying when print ? Any help would be very much appreciated!