Sending emails from Core via API
Getting started
To send an email, you must have the permission:
Email - Write
If you do not have this permission, please read the FAQ section of this documentation.
Sending an email
Use the following endpoint:
POST /api/Email/Smtp
and make sure that the request header specifies the following Content-Type:
Content-Type: multipart/form-data
In the request body that consists of a multipart/form-data body, add a body with a json value as such:
{
"FromAddress": "your@email.no",
"FromName": "Your name",
"Subject": "Some email subject",
"Recipients": [
{
"EmailAddress": "someemail1@visma.com",
"Type": 0 // Equivalent of "To"
},
{
"EmailAddress": "someemail2@visma.com",
"Type": 1 // Equivalent of "CC"
},
{
"EmailAddress": "someemail3@visma.com",
"Type": 2 // Equivalent of "BCC"
}
],
"Body": "Some text",
"CaseId": 77777 // Which case the email should be saved under. (Optional)
}
All emails sent from this endpoint will have the sender name Visma Real Estate AS noreply@webtop.no. The email will also be shown as sent from Visma Real Estate AS noreply@webtop.no under Communication on a case if CaseId is included in the request body.
Although the sender of the email will always be no-reply from a Visma email, both FromName and FromAddress are sent with the email so that if the recipient wishes to reply, both the name and email address will appear as the recipient. Additionally, a copy (CC) will be sent to FromAddress.
Adding attachments
If you want to add one or several attachments to the email, add it to the form-data of your request with a separate key value, e.g. file, file2, file3.
Visual example of a request
If you need a visual illustration of how the request should be formatted, please have a look at the images below:
A request using ‘postman’
A request using ‘talend’
Sending email based on roles of a case
If you want to send an email based on case roles, then you must first retrieve contact IDs based on a role from the endpoint:
GET flow/api/Cases/{caseid}/Roles?$filter=Type eq 'Broker'
Here you can replace Broker with any type of role, and caseid with the case you wish to retrive roles from. A list of valid case role types can be found in our Swagger documentation.
The response should look similar to:
[
{
"Id": 530000,
"Type": "Broker",
"ContactId": 999999,
"CaseId": 77777
}
]
Use the value of ContactId in another request to the following endpoint:
GET /flow/api/Contacts/{contactId}
You should get a response similar to:
{
...
"Email": "some@email.com",
...
}
Add this email to Recipients in the POST /api/Email/Smtp request as described under the section Sending an email.
Notes
The endpoints:
POST /api/v2/Email
POST /api/Email
are not available for integrators. Please refrain from using these endpoints.