Language: Deutsch · English
Send and receive e-mails from rules – send(), receive() and the NuclosMail class.
REFERENZ DEVELOPER UPDATED: JUL 2026 APPLIES TO NUCLOS 4.2026.X
On this page
The MailProvider provides methods to send and receive e-mails.
Sends a NuclosMail.
public static void send(NuclosMail mail) throws BusinessException;
package org.nuclet.businessentity;
import org.nuclet.printout.FormularAbschlussAuftragPO;
import org.nuclos.api.common.NuclosFile;
import org.nuclos.api.mail.NuclosMail;
import org.nuclos.api.provider.PrintoutProvider;
import org.nuclos.api.provider.MailProvider;
public class AbschlussAuftragRegel implements InsertFinalRule {
public void insertFinal(InsertContext context) throws BusinessException {
Auftrag a = context.getBusinessObject(Auftrag.class);
NuclosFile result = PrintoutProvider.run(FormularAbschlussAuftragPO.Deutsch_PDF, a.getId());
NuclosMail newMail = new NuclosMail();
newMail.setSubject("Abschluss eines Auftrags");
newMail.setFrom("automatic@meineFirma.de");
newMail.addRecipient("Max.Mustermann@meinKunde.de");
newMail.setMessage("Der Auftrag wurde erfolgreich abgeschlossen.");
newMail.addAttachment(result);
MailProvider.send(newMail);
}
}
Fetches e-mails from the server. With true they are deleted after retrieval, with false they remain (and are returned again next time).
public static List<NuclosMail> receive(boolean bDeleteMails) throws BusinessException;
package org.nuclet.businessentity;
import java.util.List;
import org.nuclos.api.annotation.Rule;
import org.nuclos.api.common.NuclosFile;
import org.nuclos.api.context.GenerateContext;
import org.nuclos.api.exception.BusinessException;
import org.nuclos.api.mail.NuclosMail;
import org.nuclos.api.provider.MailProvider;
import org.nuclos.api.rule.GenerateRule;
/** @name
* @description
* @usage
* @change
*/
@Rule(name="GetEmails", description="GetEmails")
public class GetEmails implements GenerateRule {
public void generate(GenerateContext context) throws BusinessException {
Materialbestellung bestellung = context.getTargetObject(Materialbestellung.class);
List<NuclosMail> allMails = MailProvider.receive(true);
for (NuclosMail mail : allMails) {
for (NuclosFile file : mail.getAttachments()) {
bestellung.insertAttachment(
file, "Bestätigungsmail von '" + mail.getFrom() + "' mit Betreff '" + mail.getSubject() + "'");
}
}
}
}
The API class NuclosMail holds all parts of a standard e-mail:
| Attribute | Meaning |
|---|---|
| From | Sender (default from system parameter SMTP Sender). |
| Recipients / CC / BCC | Recipients as string, multiple separated by semicolons. |
| Subject / Message | Subject and content. |
| ReplyTo | Reply address. |
| Headers | e.g. charset/content type (default text/plain; charset=UTF-8). |
| Attachment | List of NuclosFile attachments. |
Server configuration
SMTP/POP3 credentials are stored in the system parameters (Administration → Parameters).