gmail-imap

Python IMAP search using a subject encoded with iso-8859-1

北战南征 提交于 2019-11-30 23:44:55
From a different account, I sent myself an email with the subject Test de réception en local . Now using IMAP, I want to find that email searching by subject. When doing a search for ALL and finding the email among the output, I see: Subject: =?ISO-8859-1?Q?Test_de_r=E9ception_en_local?= So now, searching with imap, I try: M = imaplib.IMAP4_SSL('imap.gmail.com', 993) M.login('user@gmail.com', 'password') M.select('[Gmail]/All Mail') subject = Header(email_model.subject, 'iso-8859-1').encode() #email_model.subject is in unicode, utf-8 encoded typ, data = M.search('iso-8859-1', '(SUBJECT "%s")'

Python IMAP search using a subject encoded with iso-8859-1

混江龙づ霸主 提交于 2019-11-30 18:53:42
问题 From a different account, I sent myself an email with the subject Test de réception en local . Now using IMAP, I want to find that email searching by subject. When doing a search for ALL and finding the email among the output, I see: Subject: =?ISO-8859-1?Q?Test_de_r=E9ception_en_local?= So now, searching with imap, I try: M = imaplib.IMAP4_SSL('imap.gmail.com', 993) M.login('user@gmail.com', 'password') M.select('[Gmail]/All Mail') subject = Header(email_model.subject, 'iso-8859-1').encode()

Problem deleting emails in gmail using imaplib

柔情痞子 提交于 2019-11-30 05:43:31
问题 I try to remove message from inbox folder and all alright, but when i switched to All Mail folder the removing does not work. expunge() method returns ('OK', [None]) and message was not removed: >>>import imaplib >>>server = imaplib.IMAP4_SSL('imap.gmail.com','993') >>>server.login('likvidator89@gmail.com','Password') >>>server.select('inbox') >>>for i in server.search(None,'all')[1][0].split(): ... print i+"\n"+server.fetch(i,'(BODY[HEADER.FIELDS (Subject)])')[1][0][1] ... # that how i know

Need help optimizing a google apps script that labels emails

痞子三分冷 提交于 2019-11-29 21:57:40
Gmail has a issue where conversation labels are not applied to new messages that arrive in the conversation thread. issue details here We found a Google Apps Script that fixes the labels on individual messages in the Gmail Inbox to address this issue. The script is as follows: function relabeller() { var labels = GmailApp.getUserLabels(); for (var i = 0; i < labels.length; i++) { Logger.log("label: " + i + " " + labels[i].getName()); var threads = labels[i].getThreads(0,100); for (var j = 1; threads.length > 0; j++) { Logger.log( (j - 1) * 100 + threads.length); labels[i].addToThreads(threads)

Read all mails from gmail api using oauth

冷暖自知 提交于 2019-11-29 19:41:21
问题 Is there any method to read all mails ie:read and unread both from gmail Api using oauth the following link returns only new mails https://gmail.google.com/gmail/feed/atom So i want all Emails to be retrieved Please help me 回答1: On June 25, 2014 Google released new Gmail API that can be used to easily gather messages, threads, labels and more from Gmail accounts. Service is OAuth 2 protected. They provide nice client libraries for Python, .NET and Java and wonderful documentation for those

Need help optimizing a google apps script that labels emails

自闭症网瘾萝莉.ら 提交于 2019-11-28 17:58:55
问题 Gmail has a issue where conversation labels are not applied to new messages that arrive in the conversation thread. issue details here We found a Google Apps Script that fixes the labels on individual messages in the Gmail Inbox to address this issue. The script is as follows: function relabeller() { var labels = GmailApp.getUserLabels(); for (var i = 0; i < labels.length; i++) { Logger.log("label: " + i + " " + labels[i].getName()); var threads = labels[i].getThreads(0,100); for (var j = 1;

How to understand the equal sign '=' symbol in IMAP email text?

耗尽温柔 提交于 2019-11-27 23:29:51
I am currently using Python imaplib to process email text. I use fetch command to fetch the raw data email from GMail server. However, I found one thing really tricky - the equal sign '='. It is not a normal equal sign but a special symbol. For example: '=' sometimes acts as the hyphenation mark at the end of text line: Depending upon your module selections, course lecturers may also contact yo= u with preparatory work over the next few weeks. It would be wise to start = reviewing the preparatory reading lists provided on the module syllabi now = Sometimes, it acts as a escape mark similar to

IMAP: Search for messages with UID greater than X (or generally, after my last search)

廉价感情. 提交于 2019-11-27 06:37:58
问题 I'm writing a script to analyze my mailbox and want to periodically check for new messages. The search criteria would be: give me the UIDs for all emails with UID greater than X, where X is the UID of the last email I processed. Or, more generally, I'm looking for a way to only see messages since my last search. Note that I'm not looking for seen/unseen messages; the script opens the mailbox as read-only, and I'd like it to not interfere with my flags, etc. I know I can specify a date in the

gmail login failure using python and imaplib

情到浓时终转凉″ 提交于 2019-11-27 04:37:18
I'm seeking some help logging into a gmail account and downloading some emails using a python script. I'm trying to adapt an approach found here , but I'm running into a problem with step 1, accessing the account via imap. here is the code I'm starting with: import email import imaplib m = imaplib.IMAP4_SSL("imap.gmail.com",993) rc, resp = m.login('myemailaddress','mypassword') I get the following error: Traceback (most recent call last): File "email.py", line 1, in <module> import email, imaplib File "/home/will/wd/email.py", line 14, in <module> m.login('myemailaddress','mypassword') File "

How to understand the equal sign '=' symbol in IMAP email text?

筅森魡賤 提交于 2019-11-26 21:29:02
问题 I am currently using Python imaplib to process email text. I use fetch command to fetch the raw data email from GMail server. However, I found one thing really tricky - the equal sign '='. It is not a normal equal sign but a special symbol. For example: '=' sometimes acts as the hyphenation mark at the end of text line: Depending upon your module selections, course lecturers may also contact yo= u with preparatory work over the next few weeks. It would be wise to start = reviewing the