Sending KIM Messages
The KimClient
provides the method public async sendMail(mail: Mail, options?: Partial<SendMailOptions>): Promise<void>
for sending KIM messages. It takes a Mail
object, which represents a MIME Message. The method can throw a KimClientError
in some cases.
For convinient building of a Mail
object, Ti365 provides a KimMailBuilder
class, with which a mail can be created using the builder pattern.
Example
const toAddress : MailAddressType = {name: "Praxis Peter Müller", address: "praxis-peter-mueller@abc.kim.telematik"};
const mail = KimMailBuilder.withText("This is the subject", "This is the body as plain/text", toAddress);
try {
await kimClient.sendMail(mail);
} catch(error) {
if (error instanceof KimClientError) {
if (e.code === "RECIPIENTS_ERROR") { // e.g. Receipient not found in VZD or reciepient not able to receive messages > 15 MB
console.log(e.detail as RecipientsErrorDetails);
} else if (e.code === "MAIL_FORMAT_ERROR") { //e.g. Quota or remain quota exceeded
console.log(e.detail as MailFormatErrorDetails);
} else if (e.code === "KAS_CLIENT_ERROR") { // e.g. the message data time to live exceeded and the mail is no longer available
console.log(e.detail as KasClientErrorDetails);
} else {
console.log(e);
}
}
}
Searching KIM Addresses
The KimClient
provides the method public async searchReceiver(query: string, limit = 20): Promise<VzdEntry[]>
which uses the VzdClient to search for mail addresses. The query string is used in a combined search for commonName OR mail with the restrcition of the entry having a mail address at all.
const entries = kimClient.searchReceiver("Müller");