datetime - Issue about Python imaplib library on method append -
I am trying to write an imapsync software that connects from host 1 to account1@host1.com and messages and folders Account2@host2.com host2
Assume that I have already received the selected message from its UID:
msg = connection.fetch (idOne, '(RFC822)')) and msg is a good message, I tried to attach the message in the code below:
date = connection.fetch (IdOne, '( INTERNALDATE) The error is: [1] [0] date = date.split ("\" "[1] authconnection1.append (folder," ", date, message)
Value error: known type of date I try many other possible solutions (With dateutil to convert to date string) using the IAPLB timing 2 internthat I got the same error over TimeError with TimeAut object: date_time not of any known type), but no work I have searched around the network but nobody considers this problem.
Anybody I DEA? I'm getting very disappointed ...
Many Many thanks
Update:
I have a date_time problem because imaplib's "attachment" method wants date_time to be an integer of seconds, so I have written this code to retrieve that date:
Receive messages from # host1 msg = connection .fetch (idOne, '(RFC822)') # Receive this message on the date of the internal date = connection.fetch (idOne, '(INTERNALDATE)') [1] [0] .split ("\") [1] # Cast wire date object date = Pursuit. Date (date) #defines tzinfo date = date.replace (tzinfo = none) # Calculates the total second between today and the message's internal date = date = (datetime.datetime.now () - date) .total_seconds () # The message creates an app for authconnection1.append (folder, "", date, message) but now it fails with error:
type error: Expected string or buffer Then the problem has just changed ...
Any ideas?
Update (Resolved):
imaplib is not working properly, so I did an alternate solution for attachment messages with correct date / time This is my code, I hope it will help everyone:
To convert the date to the correct format:
def conversion date (date): time Import_date import_date date imported import date parser date = parser.parse (date) date = date. Timetable () withdrawal date Date code = authconnection.fetch (idOne, 'INTERNALDATE)') [Date: 1] [0] .split ("\" ") [1] # Apply to my work I wrote over the date = Convert date (date) # Ads message with correct message authconnection1.append (folder, flags, date) , Msg [1] [0] [1])
Comments
Post a Comment