Send mail to trash
The secrecyClient.mail.delete
and secrecyClient.mail.deleteDraft
methods makes a soft delete of a mail. That means that the mail is not permanently deleted, but it is marked as deleted. This allows you to create a trash folder where you can manage the deleted mails.
Delete a mail
The secrecyClient.mail.delete
is a method which attempts to delete a email using its unique id. It accepts the mail id as an argument.
The function first checks if secrecyClient is available, returning false if it’s not. If secrecyClient is available, it calls secrecyClient.mail.delete
with the mail id to delete the mail and returns a boolean indicating if the mail was deleted.
const deleteMailById = async (mailId: string): Promise<boolean> => {
// First we need to check if the secrecyClient is available
if (!secrecyClient) {
return false;
}
try {
// return true if the draft mail was deleted
const isDeleted = await secrecyClient.mail.delete(mailId);
return isDeleted;
} catch (error) {
console.error(error);
return false;
}
};
Delete a draft mail
The secrecyClient.mail.deleteDraft
is a method which attempts to delete a draft email using its unique id. It accepts the draft mail id as an argument.
The function first checks if secrecyClient is available, returning false if it’s not. If secrecyClient is available, it calls secrecyClient.mail.deleteDraft
with the mail id to delete the draft and returns a boolean indicating if the draft was deleted.
const deleteDraftMailById = async (draftMailId: string): Promise<boolean> => {
// First we need to check if the secrecyClient is available
if (!secrecyClient) {
return false;
}
try {
// return true if the draft mail was deleted
const isDeleted = await secrecyClient.mail.deleteDraft(draftMailId);
return isDeleted;
} catch (error) {
console.error(error);
return false;
}
};