Commit 765e8895 by Juan Pablo

me hace renegar los adjuntos

1 parent 95983bd4
...@@ -198,9 +198,9 @@ class Mail(ServiceBase): ...@@ -198,9 +198,9 @@ class Mail(ServiceBase):
"content": [{"type": "text/plain", "value": str(msg["Body"])}]} "content": [{"type": "text/plain", "value": str(msg["Body"])}]}
if not len(msg["Adjuntos"]) == 0: if not len(msg["Adjuntos"]) == 0:
data["attachments"] = msg["Adjuntos"] data["attachments"] = msg["Adjuntos"]
#import ipdb; ipdb.set_trace() import ipdb; ipdb.set_trace()
r = requests.post(url="https://api.sendgrid.com/v3/mail/send",data=json.dumps(data), headers=headers ) r = requests.post(url="https://api.sendgrid.com/v3/mail/send",data=json.dumps(data), headers=headers )
print(r.text) #print(r.text)
return(msg["succ"]) return(msg["succ"])
def leerDatosparaApi(self, info, data): def leerDatosparaApi(self, info, data):
...@@ -220,7 +220,10 @@ class Mail(ServiceBase): ...@@ -220,7 +220,10 @@ class Mail(ServiceBase):
msg["Body"] = objeto.read() msg["Body"] = objeto.read()
else: else:
objeto = open(filepath, "rb") objeto = open(filepath, "rb")
adj = {"content":base64.b64encode(objeto.read()),"filename": file} adj = {"content":str(base64.b64encode(objeto.read())),
"filename": file,
"disposition": "attachment",
"type": "application/pdf"}
msg["Adjuntos"].append(adj) msg["Adjuntos"].append(adj)
objeto.close() objeto.close()
return(msg) return(msg)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!