I created a test screen to display emails. How can I show the email status (Sent, Error, or Pending) in my web app using these entities Email_Content, Email_Status, Email_Definition, and Sent_Email?
I've already joined these entities, but I still can't figure out where the actual status is stored or how to display it.
I see a Sent attribute in the Sent_Email entity, but it's a DateTime type. How can I determine if the email was Sent, Failed, or is still Pending?
Do I need to join with another entity to get the actual status? If yes, which entity should I join?
Hello Rommel,
Hope you're doing well.
The Sent_Email system entity is linked to the Email_Status system entity by a 1-to-1 relationship.
This means that the ID of the Sent_Email entity is the same ID of the Email_Status entity. So you can join both accordingly.
The information you want is indeed stored in the Email_Status entity, but with some conditions that can only be verified under the hood:
1) If ( Email_Status.Sent <> NullDate() ) this means that Status = Sent
2) If ( Email_Status.Error_Count > 0 and Email_Status.Sent = NullDate() ) this means that Status = Error
3) If (Email_Status.NextRun <> NullDate() and Email_Status.Sent = NullDate() ) this means that Status = Pending
Hope that this helps you!
Kind regards,
Rui Barradas
To display the email status (Sent, Error, or Pending) in your web app using the Email_Content, Email_Status, Email_Definition, and Sent_Email entities, you can follow these steps:
Email_Content
Email_Status
Email_Definition
Sent_Email
Add Dependencies: Add the following System entities as dependencies to your module:
You can do this by opening the Manage Dependencies dialog in Service Studio and searching for the required entities Emails API.
Manage Dependencies
Create a Data Entity or Structure (Optional): If you want to display email-related details, such as recipient email address, subject, and status, consider creating a local entity or structure to organize and display the information in your web screens.
Fetch Data Using an Aggregate:
To
Subject
Email_Status_Id
Email_Status.Id
Here's an example of how these entities can be joined:
Sent_Email.Email_Status_Id = Email_Status.Id
Sent_Email.Email_Definition_Id = Email_Definition.Id
Sent_Email.Id = Email_Content.Sent_Email_Id
Filter the aggregate as needed, for example, by user ID, a specific recipient email, or status.
Create a Web Screen to Show the Data:
Sent_Email.To
Sent_Email.Subject
Email_Status.Label
Display and Update the Status:
Status
Debugging Issues:
If emails fail to send, you can find related error logs in the Service Center's Monitoring section under "Email".
These steps will help you effectively display the email status in your web application and enable users to monitor email statuses based on the system entities provided by the OutSystems platform. Let me know if you need further details!
In the OutSystems Emails API, the actual status of an email (e.g., Sent, Error, or Pending) is represented by the Name attribute in the Email_Status entity. This attribute stores a human-readable string that indicates the status of the email.
Name
To determine the status of an email, you need to join the Sent_Email entity with the Email_Status entity using the Email_Status_Id foreign key in Sent_Email. After establishing this relationship, you can fetch the value of the Name attribute in Email_Status for each email Emails API.
This approach allows you to display statuses such as "Sent", "Error", or "Pending" on your web application. If you're looking for the date and time an email was sent, you can use the Sent attribute from the Sent_Email entity How to find when the last email was sent.
Sent
If the Email_Status entity does not provide the expected attributes (Name or Label) for the email status in your query or join with Sent_Email, ensure that your use of the Email_Status entity follows its correct implementation according to the OutSystems Emails API. The actual status values (e.g., Sent, Error, or Pending) are stored in this entity, where each status corresponds to an ID (Id).
Label
Id
Here’s how you can find and confirm the status of an email:
The Id column in Email_Status corresponds to a predefined set of email statuses in the OutSystems platform. These statuses are system-defined. In a standard setup, they typically map to:
0
1
2
You must map these IDs to their respective statuses manually in your application logic if the Email_Status entity does not have a descriptive attribute (e.g., Name or Label) available Emails API.
StatusMapping: 0 → Pending 1 → Sent 2 → Error
Use this mapping in your logic to interpret the Email_Status_Id value retrieved from Sent_Email.
The email status (Sent, Error, or Pending) is fundamentally stored in the Email_Status_Id attribute of the Sent_Email entity. This links to the Email_Status entity, where you can cross-reference its predefined Id values. When descriptive labels (Name or Label) are unavailable in Email_Status, you must use manual mappings for the status values Emails API.