Ok, i am a novice (read: VERY NOVICE) programmer. I have managed to cobble together this python script to export all mail messages into a csv file. I have a list of all Message ID’s and i am iterating through the list to call the API and append it to a csv doc.
import urllib3
import json
import csvwith open(‘blim1.csv’, newline=‘’) as csvfile:
idents = csv.reader(csvfile, delimiter=’ ‘, quotechar=’|')
datas = list()
for row in idents:http = urllib3.PoolManager() r = http.request('GET', "".join(row)+'?include_body=1&api_token=token') mails = json.loads(r.data.decode('utf-8')) datas.append(mails) #{'origin': '127.0.0.1'}
with open(‘test.csv’, “w”, encoding=“utf-8”) as output:
writer = csv.writer(output,delimiter=‘,’,lineterminator=‘\n’)
for data in datas:
writer.writerow([data])
Potentially I am doing this in a very stupid fashion. Is there anyway to export all mail messages with the body in it that is more efficient than this and have it in a usable csv format(i am guessing yes).
Thanks in advance.