L
L
lnk222019-07-31 14:40:56
Python
lnk22, 2019-07-31 14:40:56

Why can't I specify 2 join subject and To?

You need to parse the gmail box to the account of sent letters, you need to parse the fields to whom. topic, well, and a request for a specific date.

r = {"To": None, "Subject": None}
        for i in response["payload"]["headers"]:
            if i["name"] in r.keys():
                r[i["name"]] = i["value"]

here we actually parse the email, the subject.
then I generate the result, here is the heading in it, for some reason I can’t specify 2 join
subject and To
user_id='me'
    req_date = ("%s-%s-%s" % (flags.year,flags.month,flags.day))
    date = datetime.datetime.strptime(req_date , '%Y-%m-%d').date()
    before_date = return_tomorrows_date(date)
    credentials = get_credentials()
    http = credentials.authorize(httplib2.Http())
    service = discovery.build('gmail', 'v1', http=http)
    query = ('from:%s after:%s before:%s' % (flags.sender, date, before_date))
    messages = ListMessagesMatchingQuery(service,user_id,query)
    generate_results(req_date,flags.sender,",".join([x["Subject"] for x in messages])) или  generate_results(req_date,flags.sender,",".join([x["To"] for x in messages]))

if you specify it separately, everything works, but I need to join both to and subject
and output it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question