Questions tagged [imaplib]

Python module to provide an Internet Message Access Protocol (IMAP) client implementation. This protocol lets you access mail folders stored on a central mail server, as if they were local.

Python module to provide an Internet Message Access Protocol (IMAP) client implementation. This protocol lets you access mail folders stored on a central mail server, as if they were local.

694 questions
0
votes
1 answer

How to decode the email body?

I recently trying to get wordpress email verification link using imaplib, but the message was like a bit crooked, not able to get decode, I tried html unescape, but it didnt worked, can anyone please help me how to decode & get verification link…
sunny9495
  • 93
  • 3
  • 14
0
votes
2 answers

how to replace spaces with commas in a tuple?

I need to get a count of the emails received daily in a Gmail mailbox and save that count in a table. To do this I am using the imaplib: import imaplib import re obj = imaplib.IMAP4_SSL('imap.gmail.com', 993) obj.login('xxx@gmail.com',…
0
votes
1 answer

Fetching mails from gmail using IMAP concurrently

I want to fetch multiple mails message, by theirs ids from Gmail and I'm using Imap for that. It worked great until I tried to speed things up with ThreadPull executor (even for 2 executors). if anyone can think about what is the reason for that…
Sprint21
  • 89
  • 6
0
votes
2 answers

How to move message to Trash in gmail imap?

I am creating an application in which I need to delete mail using IMAP in gmail. But when I set the flag to delete the message moves to spam folder instead of trash or directly deletion. Is there any way to move message to trash? UPDATE Now my…
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256
0
votes
0 answers

IMAPLIB Search command returns false values

I have the following code to check messages in my inbox: M = imaplib.IMAP4_SSL('imap.url.com') M.login('myemail@my.com','myPassword') M.select('inbox') typ, data = M.search(None, 'ALL') print(data) Let's say i have two email in my inbox, the output…
0
votes
1 answer

Python name 'latest_email_uid' is not defined

I am trying to write a Python(3.83.64-bit) which download the attachment of the emails to a file location on the Windows environment. I am using here for the instructions of the following article (…
Erik hoeven
  • 1,442
  • 6
  • 26
  • 41
0
votes
2 answers

Python Script to get attachments from gmail account

This code runs and does download the attachments as expected. That said, It writes all attachments to the directory on my PC. I only want to include an attachment with a .html file type. Anything else should be omitted. Secondly, I would like it to…
James Cook
  • 334
  • 4
  • 16
0
votes
1 answer

Python 3 Imaplib - (Errors : EXPUNGE failed ,BAD [b'Command Argument Error. 11'] ) Unable to delete the mails from Microsoft service account

Trail 1 : result, data = mail.uid("STORE", str(message_id), "+X-GM-LABELS", '"\\Trash"') o/p : BAD [b'Command Argument Error. 11'] Trail 2 : result, data = mail.uid('STORE', str(message_id) , '+FLAGS', '(\\Deleted)') print("Deleted the mail : "…
0
votes
2 answers

AttributeError: "NoneType" object has no attribute 'decode'

I am trying to read an email from my gmail inbox in Python3. So I followed this tutorial : https://www.thepythoncode.com/article/reading-emails-in-python My code is the following : username = "*****@gmail.com" password = "******" # create an IMAP4…
lolaa
  • 181
  • 1
  • 4
  • 11
0
votes
0 answers

Python imaplib module - How to extract date in (GMT-06:00) Central Time (US & Canada ) format

Using Imaplib in Python , I want to extract the datetime of the email in (GMT-06:00) Central Time (US & Canada) format. Below are the sample Dates when using msg["date"] Tue, 14 Jul 2020 08:30:01 +0530 Tue, 14 Jul 2020 02:59:49 +0000 Mon, 13 Jul…
0
votes
1 answer

Imap Error while checking email in python

I am using Python 3.7.7 and wanted to check my gmail emails with this code: import smtplib import time import imaplib import email mail = imaplib.IMAP4_SSL("imap.gmail.com") mail =…
math scat
  • 310
  • 8
  • 17
0
votes
1 answer

why we should write None in imaplib search method

Here is code: box = imaplib.IMAP4_SSL(HOST,PORT) box.login(sender,password) box.select("INBOX") data = box.search(None, "all") I can not understand one thing, why I have to write None in search method?every tutorial I have found about using…
0
votes
1 answer

Email monitoring in an infinite while loop. Any downsides/ better ideas?

I am writing a short script to monitor my inbox and get notified at every new incoming email. So far, I am using an infinite while loop like this: msg_id_check = None while True: result, data = mail.fetch(mail.select('INBOX')[1][0], "(RFC822)") …
elbashmubarmeg
  • 330
  • 1
  • 9
0
votes
1 answer

How do I move emails into folders using the IMAP library in python?

How do I move emails into folders using the IMAP library in python? Trying to move an email from one folder into another. I have the uid of the emails that I want to move.
0
votes
0 answers

Download Email attachments - Timeout Error

I am trying to download Email attachments in Python. I am mainly drawing on this: Downloading multiple attachments using imaplib I want to run the code once per week to download all new attachments (I delete old emails). It was working (although…
Florian Seliger
  • 421
  • 4
  • 16