def onSaveMail():
    # save selected message in file
    mailfile = asksaveasfilename(title='PyMail Save File', initialdir='.')
    if mailfile:
        if allModeVar.get():
            for i in range(1, len(msgList)+1):
                pymail.savemessage(i, mailfile, msgList)
        else:
            msgnum = selectedMsg()
            if not (1 <= msgnum <= len(msgList)):
                showerror('PyMail', 'No message selected')
            else:
                pymail.savemessage(msgnum, mailfile, msgList)    
def onSaveMail():
    # save selected message in file
    mailfile = asksaveasfilename(title='PyMail Save File', initialdir='.')
    if mailfile:
        if allModeVar.get():
            for i in range(1, len(msgList) + 1):
                pymail.savemessage(i, mailfile, msgList)
        else:
            msgnum = selectedMsg()
            if not (1 <= msgnum <= len(msgList)):
                showerror('PyMail', 'No message selected')
            else:
                pymail.savemessage(msgnum, mailfile, msgList)
def onSaveMail():
    # save selected message in file
    if allModeVar.get():
        mailfile = myasksaveasfilename_all()
        if mailfile:
            try:
                # maybe this should be a thread
                for i in range(1, len(msgList) + 1):
                    pymail.savemessage(i, mailfile, msgList)
            except:
                showerror("PyMail", "Error during save")
    else:
        msgnum = selectedMsg()
        if not (1 <= msgnum <= len(msgList)):
            showerror("PyMail", "No message selected")
        else:
            mailfile = myasksaveasfilename_one()
            if mailfile:
                try:
                    pymail.savemessage(msgnum, mailfile, msgList)
                except:
                    showerror("PyMail", "Error during save")
def onSaveMail():
    # save selected message in file
    if allModeVar.get():
        mailfile = myasksaveasfilename_all()
        if mailfile:
            try:
                # maybe this should be a thread
                for i in range(1, len(msgList) + 1):
                    pymail.savemessage(i, mailfile, msgList)
            except:
                showerror('PyMail', 'Error during save')
    else:
        msgnum = selectedMsg()
        if not (1 <= msgnum <= len(msgList)):
            showerror('PyMail', 'No message selected')
        else:
            mailfile = myasksaveasfilename_one()
            if mailfile:
                try:
                    pymail.savemessage(msgnum, mailfile, msgList)
                except:
                    showerror('PyMail', 'Error during save')