Hi. There is a task to send emails with multiple mime parts using the REST API.
I didn’t really understand from the documentation how to do this in JSON(.
REST API 1.1.3.1
Domino 12.0.2FP6
Hi. There is a task to send emails with multiple mime parts using the REST API.
I didn’t really understand from the documentation how to do this in JSON(.
REST API 1.1.3.1
Domino 12.0.2FP6
@Aleksandr , yes, you can use the PIM API.
The PIM API uses the mail file associated with the jwt user.
To create a mime message, first base64 encode your mime message then
curl -X 'POST' \
'https://your_drapi_server/api/pim-v1/mime?send=false' \
-H 'accept: application/json' \
-H 'Authorization: Bearer your_bearer_token' \
-H 'Content-Type: text/base64' \
-d 'your base64 encoded content'
Look at the swagger documentation for more details:
Thanks, but apparently my skills are not enough to understand)).
I was considering the option https://drapi.server/api/pim-v1/message
Can you tell me how to generate JSON in which there will be content-type = multipart/mixed, and the email body itself contains a file, plain text and formatted text?
I found MessagePart in the documentation (In the “Schemas” section), but I still couldn’t generate a working json (((.
I’ll be grateful for your help!
Will there be any hints?)))
So if you’re trying to generate MIME, that’s not really something I can describe here, MIME is a standard and googling for creating MIME or understanding MIME will get you good results.
If you are just trying to send an email, you don’t necessarily need MIME. The POST pim-v1/message
swagger has an example:
{
"bccto": [
"johndoe@marauders.com",
"rj@hcl.com"
],
"body": {
"content-type": "text/html; charset=utf-8",
"encoding": "Base64",
"message": "PGh0bWwgeG1sbnM6bz0zRCJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiIHhtbG5zOnc9M0QidXJuOnNjaGVtYT1zLW1pY3Jvc29mdC1jb206b2ZmaWNlOndvcmQiDQoJeG1sbnM6bT0zRCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS8yMD0gMDQvMTIvb21tbCIgeG1sbnM9M0QiaHR0cDovL3d3dy53My5vcmcvVFIvUkVDLWh0bWw0MCI+IDxoZWFkPg0KPG1ldGEgaHR0cC1lcXVpdj0zREM9b250ZW50LVR5cGUgY29udGVudD0zRCJ0ZXh0L2h0bWw7IGN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g0KCWRpdi5Xb3JkU2VjdGlvbjEgew0KCQlwYWdlOiBXb3JkU2VjdGlvbjE7DQoJfQ0KCS0tPg0KPC9zdHlsZT4NCjwvaGVhZD4NCg0KPGJvZHkgbGFuZz0zREVOLVVTIGxpbms9M0QiIzA1NjNDMSIgdmxpbms9M0QiIzk1NEY3MiI+DQoJPGRpdiBjbGFzPXM9M0RXb3JkU2VjdGlvbjE+DQoJCTxwIGNsYXNzPTNETXNvTm9ybWFsPlRoaXMgaXMgYSB0ZXN0IGVtYWlsDQoJCQk8bzpwPjwvbzpwPg0KCQk8L3A+DQoJPC9kaXY+DQo8L2JvZHk+DQoNCjwvaHRtbD4="
},
"copyto": [
"John Doe <johndoe@marauders.com>"
],
"from": "RJ De Jesus <rj@hcl.com>",
"priority": 1,
"subject": "Sample Email",
"to": [
"John Doe <johndoe@marauders.com>",
"RJ De Jesus <rj@hcl.com>"
]
}
The message area is base64 encoded html. If you copy that message value base 64 decode it (there are base64 decoders online) you can see what it looks like:
<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D"urn:schema=s-microsoft-com:office:word"
xmlns:m=3D"http://schemas.microsoft.com/office/20= 04/12/omml" xmlns=3D"http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv=3DC=ontent-Type content=3D"text/html; charset=3Dutf-8">
<meta name=3DGenerator content=3D="Microsoft Word 15 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face {
font-family: "Cambria Math";
panose-1: 2 4 5 3 5 4 6 3 2 4;
}
@font-face {
font-family: Calibri;
panose-1: 2 15 5 2 2 2 4 3 2 4;
}
/* Style Definitions */
p.MsoNormal,
li.MsoNormal,
div.MsoNormal {
margin: 0in;
margin-bottom: .0001pt;
font-size: 11.0pt;
font-family: "Calibri", sans-serif;
}
span.EmailStyle17 {
mso-style-type: personal-compose;
font-family: "Calibri", sans-serif;
color: windowtext;
}
.MsoChpDefault {
mso-style-type: export-only;
font-family: "Calibri", sans-serif;
}
@page WordSection1 {
size: 8.5in 11.0in;
margin: 1.0in 1.0in 1.0in 1.0in;
}
div.WordSection1 {
page: WordSection1;
}
-->
</style>
</head>
<body lang=3DEN-US link=3D"#0563C1" vlink=3D"#954F72">
<div clas=s=3DWordSection1>
<p class=3DMsoNormal>This is a test email
<o:p></o:p>
</p>
</div>
</body>
</html>
The net result is an email
I don’t know why there’s so much style information in that html, but there it is.
If you wanted to do attachments and inline images, then, yes, you’d need MIME and would need to use the POST pim-v1/mime
endpoint.
MIME is much more complicated and there’s plenty of online information on creating MIME. That topic is out of DRAPI’s scope.
The one thing you can do in Notes Mail is save an existing email to .eml and that will create a MIME message file for that email (On Windows, open that email message and choose “File / Save As”, not sure what the menu is for mac) , from that, you can find the structure and use it for online learning of that topic.
Thanks!
Thanks, I’ll try to figure it out.