Python IMAP4 how to reply to an email with a given UID or last email in Inbox
I have been able to login my gmail with IMAP4 and get the last UID , but I dont know how to reply to the last email in the inbox my python automation code:
self.mail = imaplib.IMAP4_SSL('imap.gmail.com')
self.mail.login(self.data["emailUsername"], self.data["emailPassword"])
self.mail.list()
self.mail.select("inbox")
subjectStr = '(HEADER Subject ' + "\"" + mySubject + "\"" + ')'
result, UIDemailsWithGivenSubject = self.mail.uid('search', None, subjectStr)
ids_string = UIDemailsWithGivenSubject[0].decode("utf-8")
ids_string_list = ids_string.split(" ")
self.lastEmailUid = ids_string_list[-1]
Now how do I respond to the last email or respond/reply with a given UID.