Hi Chris - Here is the code as I entered it - I have put in bold the bits I changed from EKR's example. I am a python novice and so I doubt I can be of much help I'm afraid.
I would like to ditch the attachments to try and get the file size down - at the moment the leo file is about 1 gig in size! ta IH # https://groups.google.com/forum/?fromgroups#!searchin/leo-editor/imaplib/leo-editor/i_U-PBv0Ek0/c0XsmlI_UugJ @language python import imaplib def munge(part): s = g.toUnicode(repr(part[0][1])) s = s.strip("'") return s.replace('\\r\\n','\n') m = imaplib.IMAP4_SSL('*imap.fastmail.com*',993) # Require SSL: Yes m.login( '*[email protected]*',' *my_password_goes_here_because_it_is_a_fastmail_account_it_is_a_special_app_password* ') *g.es('connected to fastmail.com')* # for z in m.list(): # print(z) try: box = '' # 'INBOX' m.select(box,True) # readonly. ok, aList = m.search(None,'ALL') if ok == 'OK': parent = p.insertAsLastChild() parent.h = box aList = [g.toUnicode(z) for z in aList] nums = aList[0].split() for num in nums: # ok,data = m.fetch(num,'(RFC822)') # Gets everything. ok,part = m.fetch(num,"(UID BODY[TEXT])") if ok != 'OK': continue print('reading %s %s' % (box,num)) child = parent.insertAsLastChild() body = munge(part) ok,part = m.fetch(num,"(UID BODY[HEADER.FIELDS (FROM)])") if ok == 'OK': body = munge(part) + body child.b = '@nocolor\n\n' + body ok,part = m.fetch(num,"(UID BODY[HEADER.FIELDS (SUBJECT)])") if ok == 'OK': head = munge(part) tag = 'Subject: ' if head.startswith(tag): head = head[len(tag):] child.h = head.replace('\n','') else: child.h = '%s %s' % (box,num) finally: m.close() m.logout() p.contract() c.redraw() *g.es('done')* On Friday, 8 February 2019 16:53:26 UTC, Chris George wrote: > > So I copy and pasted the code from scripts.leo into a node and save the > file. Then I ran ctrl-b. > > errors writing: <string-file> > undefined section: << your login name>> > referenced from: email > no script selected > So then I said "hmmf, looks like I need to change that to my email > address" and get this: > > errors writing: <string-file> > undefined section: <<[email protected] <javascript:>>> > referenced from: email > no script selected > > > Mainly due to my lack of python knowledge that is the end of that. I have > no time to fiddle today. > > > Chris > > > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
