I'm trying to send an email via the Gmail API using Python, I want to iclude the signature. I'm able to successfuly get the signature using the following funciotn:
def addSignature(service):
sigtanture = service.users().settings().sendAs().get(userId=USER, sendAsEmail='example@example.com').execute()
return sigtanture['signature']
addSignature(SERVICE)
However, at the time of creating the message that I'll send, how do I append the Signature?
def CreateMessage(sender, to, subject, message_text, signature):
message = MIMEMultipart('alternative')
message['to'] = to
message['from'] = sender
message['subject'] = subject
message[???] = signature
raw = base64.urlsafe_b64encode(message.as_bytes())
raw = raw.decode()
body = {'raw': raw}
return body
I'm trying to send the message:
thebody = CreateMessage(USER, 'to@example.com', 'TestSignatureAPI','testing', addSignature(SERVICE))
SendMessage(SERVICE, USER, thebody)
Thank you!