Skip to main content
Version: 2026.0

mail

JDito Funktionen zum Umgang mit eMails

Methods

addAttachment

addAttachment(pMailID, pContent, pContentType, pFileName, pInline, pHeader?, pRelatedId?): void

Adds an attachment to the mail.

Note: There are often problems with the contenttype if no matching DataHandler is available.

Parameters

pMailID
string | number | boolean

The ID of the email.

pContent
any

The contents of the email as an object.

pContentType
string | number | boolean

The Mime type of the attachment.

pFileName
string | number | boolean

The file name of the attachment (optional).

pInline
boolean

'true' adds the attachment as an inline object; otherwise as an attachment.

pHeader?
string[][]

The header of the attachment; 'null' for none.

pRelatedId?
string | number | boolean

All elements with the same ID are grouped into a MimeMultiPart attachment (multipart/related). Specify 'null' if you want to send a separate email for each of them.

Returns

void

Throws

May throw an exception.


addBase64Attachment

addBase64Attachment(pMailID, pBase64Content, pContentType, pFileName, pInline, pHeader?, pRelatedId?): void

Adds binary data as an attachment.

Parameters

pMailID
string | number | boolean

The ID of the email.

pBase64Content
string | number | boolean

The contents of the email as a Base64-encoded string.

pContentType
string | number | boolean

The Mime type of the attachment.

pFileName
string | number | boolean

The file name of the attachment (optional).

pInline
boolean

'true' adds the attachment as an inline object; otherwise as an attachment.

pHeader?
string[][]

The header of the attachment; 'null' for none.

pRelatedId?
string | number | boolean

All elements with the same ID are grouped into a MimeMultiPart attachment (multipart/related). Specify 'null' if you want to send a separate email for each of them.

Returns

void

Throws

May throw an exception.


addHeader

addHeader(pMailID, pHeaderName, pHeaderContent): void

Adds header information to an email.

Parameters

pMailID
string | number | boolean

The ID of the email.

pHeaderName
string | number | boolean

The name of the header information.

pHeaderContent
string | number | boolean

The contents of the header information.

Returns

void

Throws

May throw an exception.

Example

var email = mail.newMail();
mail.addHeader(email, "campaign", vars.getString("$image.campaignid"));

addRecipients

addRecipients(pMailID, pRecipientType, pRecipients): void

Adds recipients to an email.

Parameters

pMailID
string | number | boolean

The ID of the email.

pRecipientType
string | number | boolean

The type of recipient (mail.RECIPIENT_*)

pRecipients
string[]

The recipients, as a string array.

Returns

void

Throws

May throw an exception.

Example

var email = mail.newMail();
mail.addRecipients(email, mail.RECIPIENT_TO, ["m.dean@domain.local", "info@domain.local"]); mail.addRecipients(email, mail.RECIPIENT_CC , ["lisa.sommer@domain.local"); mail.addRecipients(email, mail.RECIPIENT_BCC , [²mailbridge@domain.local"]);

addText

addText(pMailID, pText, pTextType, pEncoding?, pRelatedId?): void

Adds text to an email.

Parameters

pMailID
string | number | boolean

The ID of the email.

pText
string | number | boolean

The text to be added.

pTextType
string | number | boolean

The Mime type of the text, e.g. "text/plain" or "text/html".

pEncoding?
string | number | boolean

The encoding to be used.

pRelatedId?
string | number | boolean

All elements with the same ID are grouped into a MimeMultiPart attachment (multipart/related). Specify 'null' if you want to send a separate email for each of them.

Returns

void

Throws

May throw an exception.


clearMail

clearMail(pMailID): boolean

Deletes an email from the cache.

Parameters

pMailID
string | number | boolean

The ID of the email.

Returns

boolean

'true' if the email was deleted successfully.

Example

var sentdate = vars.getString("$sys.date");
var email = mail.newMail();
mail.setSender(email, sender);
mail.addRecipients(email, mail.RECIPIENT_TO, recipient);
mail.setSubject(email, subject);

mail.sendMailAs("mailbridge", email);
mail.clearMail([email]);

clearRecipients

clearRecipients(pMailID, pRecipientType): void

Clears all recipients of the given type from the mail.

Parameters

pMailID
string | number | boolean

The ID of the email.

pRecipientType
string | number | boolean

The type of recipient (mail.RECIPIENT_*)

Returns

void

Throws

May throw an exception.

Example

var email = mailId = mail.newMail(emlFileContent, mail.FORMAT_MIME);
mail.clearRecipients(email, mail.RECIPIENT_TO); mail.clearRecipients(email, mail.RECIPIENT_CC); mail.clearRecipients(email, mail.RECIPIENT_BCC);

copyMessage

copyMessage(pStoredMessageInfo, pSourceFolder, pDestinationFolder): boolean

Copies a message from one folder to another. For this purpose, the IMAP server copy function is used.

This function can only be called at the server.

Parameters

pStoredMessageInfo
string | number | boolean

The ID of the message.

pSourceFolder
string | number | boolean

The source folder.

pDestinationFolder
string | number | boolean

The destination folder.

Returns

boolean

'true' if the file was copied.

Throws

May throw an exception.

Example

//Get messages
var messages = mail.getMessagesFor("l.hagg", "Inbox");

// Get the last message as an object
var message = mail.getMessage(messages[messages.length-1], "Inbox");
var copied = mail.copyMessage(message[mail.MAIL_ID], "Inbox", "Important Emails");

copyMessage2

copyMessage2(pStoredMessageInfo, pSourceFolder, pDestinationFolder): string[]

Copies a message from one folder to another. Copies the message from the mail server to the ADITO server and back.

Should only be used if the standard copy function (e.g. Exchange server function) does not work.

This function can only be called at the server.

Parameters

pStoredMessageInfo
string | number | boolean

The ID of the message.

pSourceFolder
string | number | boolean

The source folder.

pDestinationFolder
string | number | boolean

The destination folder.

Returns

string[]

String [] with the IDs of the messages that were copied. If an element could not be copied, the array element is 'null'.

Throws

May throw an exception.

Example

// Get messages
var messages = mail.getMessagesFor("l.hagg", "Inbox");

// Get the last message as an object
var message = mail.getMessage(messages[messages.length-1], "Inbox");
mail.copyMessage2(message[mail.MAIL_ID], "Inbox", "Important Emails);

copyMessageFor

copyMessageFor(pUserTitle, pStoredMessageInfo, pSourceFolder, pDestinationFolder): boolean

Copies a message from one folder to another. For this purpose, the IMAP server xopy function is used.

This function can only be called at the server.

Parameters

pUserTitle
string | number | boolean

The login name of the user.

pStoredMessageInfo
string | number | boolean

The ID of the message.

pSourceFolder
string | number | boolean

The source folder.

pDestinationFolder
string | number | boolean

The destination folder.

Returns

boolean

'true' if the file was copied.

Throws

May throw an exception.

Example

// Get messages
var messages = mail.getMessagesFor("l.hagg", "Inbox");

// Get the last message as an object
var message = mail.getMessage(messages[messages.length-1], "Inbox");
mail.copyMessageFor("l.hagg", message[mail.MAIL_ID], "Inbox", "Important Emails");

copyMessageFor2

copyMessageFor2(pUserTitle, pStoredMessageInfo, pSourceFolder, pDestinationFolder): string[]

Copies a message from one folder to another.

Does not use the IMAP server copy function, but copies the message from the mail server to the ADITO server and back.

Should only be used if mail.copyMessageFor() cannot be used.

This function can only be called at the server.

Parameters

pUserTitle
string | number | boolean

The login name of the user.

pStoredMessageInfo
string | number | boolean

The ID of the message.

pSourceFolder
string | number | boolean

The source folder.

pDestinationFolder
string | number | boolean

The destination folder.

Returns

string[]

String [] with the IDs of the messages that were copied. If an element could not be copied, the array element is 'null'.

Throws

May throw an exception.

Example

// Get messages
var messages = mail.getMessagesFor("l.hagg", "Inbox");

// Get the last message as an object
var message = mail.getMessage(messages[messages.length-1], "Inbox");
mail.copyMessageFor2("l.hagg", message[mail.MAIL_ID], "Inbox", "Important Emails");

deleteMail

deleteMail(pIdentifier): boolean

Deletes the mail with the parameters you passed.

Parameters

pIdentifier
string | number | boolean

The ID of the email.

Returns

boolean

'true' if the email was deleted.

Throws

May throw an exception.

Example

var deleted = mail.deleteMail("12");

deleteMessage

deleteMessage(pStoredMessageInfo, pFolderName): boolean

Deletes a message associated with the ID of a logged-in user.

This function can only be called at the server.

Parameters

pStoredMessageInfo
string | number | boolean

The ID of the message.

pFolderName
string | number | boolean

The name of the folder to be used.

Returns

boolean

'true' if the message was deleted.

Throws

May throw an exception.

Example

// Get messages
var messages = mail.getMessagesFor("l.hagg", "Inbox");
// Get the last message as an object
var message = mail.getMessage(messages[messages.length-1], "Inbox");

// Display sender
var sender = message[mail.MAIL_SENDER];
question.showMessage(sender);

// Delete message, if desired
var answer = question.askQuestion("Delete message?", question.QUESTION_YESNO, "");

if (answer == "true")
mail.deleteMessage(message[mail.MAIL_ID], "Inbox");

deleteMessageFor

deleteMessageFor(pUserTitle, pStoredMessageInfo, pFolderName): boolean

Deletes a message associated with the ID of a logged-in user.

This function can only be called at the server.

Parameters

pUserTitle
string | number | boolean

The login name of the user.

pStoredMessageInfo
string | number | boolean

The ID of the message.

pFolderName
string | number | boolean

The name of the folder to be used.

Returns

boolean

'true' if the message was deleted.

Throws

May throw an exception.

Example

// Get messages
var messages = mail.getMessagesFor("l.hagg", "Inbox");
// Get the last message as an object
var message = mail.getMessage(messages[messages.length-1], "Inbox");

// Display sender
var sender = message[mail.MAIL_SENDER];
question.showMessage(sender);

// Delete message, if desired
var answer = question.askQuestion("Delete message?", question.QUESTION_YESNO, "");

if (answer == "true")
mail.deleteMessageFor("l.hagg", message[mail.MAIL_ID], "Inbox");

extractAddress

extractAddress(pAddress): string

Extracts the email address (x[at]x.x) from a complete address that may contain a readable part.

Parameters

pAddress
string | number | boolean

The complete address.

Returns

string

The email address.

Throws

May throw an exception.

Example

var messages = mail.getMessagesFor("r.argo", "Inbox");
var message = mail.getMessage(messages[messages.length-1], "Inbox");
var sender = message[mail.MAIL_SENDER];
var sendermail = mail.extractAddress(sender);
question.showMessage(sendermail);

getAttachment

getAttachment(pMail, pPosition): string

Returns the attachment that is located at the specified position of an email.

Parameters

pMail
any

The email.

pPosition
number

The position of the attachment.

Returns

string

The attachment, Base64-encoded.

Throws

May throw an exception.

Example

var email = mail.getMail("; DB; AO_DATEN; ASYS_MAILREPOSIT; 83; ");
var attachment = mail.getAttachment(email, 1);

getAttachmentHeader

getAttachmentHeader(pMail, pPosition, pHeaderName): string[]

Returns the headers of an attachment.

Parameters

pMail
any

The email.

pPosition
number

The position of the attachment.

pHeaderName
string | number | boolean

The name of the header to be retrieved.

Returns

string[]

The header values or an empty array if none were found.

Throws

May throw an exception.

Example

var email = mail.getMail("; DB; AO_DATEN; ASYS_MAILREPOSIT; 83; ");
var attachmentHeader = mail.getAttachmentHeader(email, 1, "campaign");

getAttachmentHeaderNames

getAttachmentHeaderNames(pMail, pPosition): string[]

Returns the header names of an attachment.

Parameters

pMail
any

The email.

pPosition
number

The position of the attachment.

Returns

string[]

The header names or an empty array if none were found.

Throws

May throw an exception.

Example

var email = mail.getMail("; DB; AO_DATEN; ASYS_MAILREPOSIT; 83; ");
var attachmentHeadernames = mail.getAttachmentHeaderNames(email, 1);

getAttachmentInfos

getAttachmentInfos(pMail): string[]

Retrieves information on the attachments of an email.

Parameters

pMail
any

The email.

Returns

string[]

The attachments in a multi-string array:

Throws

May throw an exception.

Example

var email = mail.getMail("; DB; AO_DATEN; ASYS_MAILREPOSIT; 83; ");
var atts = mail.getAttachmentInfos(email);

getCachedMail

getCachedMail(pMailID): Map<any, any>

Retrieves the email with the ID passed from the cache.

Parameters

pMailID
string | number | boolean

The ID of the email.

Returns

Map<any, any>

The email from the email cache.

Throws

May throw an exception.

Example

var email = mail.getCachedMail("32321546");

getHeader

getHeader(pMail, pName): string[]

Returns the headers of an email.

Parameters

pMail
any

The email.

pName
string | number | boolean

The name of the header whose information you want to retrieve.

Returns

string[]

The header values or an empty array if no matching headers were found.

Throws

May throw an exception.

Example

var email = mail.getMail("; DB; AO_DATEN; ASYS_MAILREPOSIT; 83; ");
var mailheader = mail.getHeader(email, "org");

getHeaderNames

getHeaderNames(pMail): string[]

Returns the names of the email headers.

Parameters

pMail
any

The email.

Returns

string[]

The names of the email headers, as a string array or an empty array if no matching header values exist.

Throws

May throw an exception.

Example

var email = mail.getMail("; DB; AO_DATEN; ASYS_MAILREPOSIT; 83; ");
var mailheaders = mail.getHeaderNames(email);

getMail

getMail(pIdentifier): Map<any, any>

Returns the email with the parameters you passed.

Parameters

pIdentifier
string | number | boolean

The ID of the email.

Returns

Map<any, any>

The email or 'null', if no email exists. To query the contents of the email, you can use the email constants.

Throws

May throw an exception.

Example

var email = mail.getMail("; DB; ADITO; ASYS_MAILREPOSITORY; 057ee1f2-5e0e-46e2-9bd0-eae0f6ba1a49; ");
var sender = email[mail.MAIL_SENDER];

getMessage

getMessage(pStoredMessageInfo, pFolderName): Map<any, any>

Returns the entire message associated with the ID of a logged-in user you passed.

This function can only be called at the server.

Parameters

pStoredMessageInfo
string | number | boolean

The ID of the message.

pFolderName
string | number | boolean

The name of the folder to be used.

Returns

Map<any, any>

The message as a map.

Throws

May throw an exception.

Example

// Get the IDs of the messages in the Inbox
var messages = mail.getMessagesFor("c.rath", "Inbox");

// Get the entire message object for the last ID
// and retrieve the sender
var message = mail.getMessage(messages[messages.length-1], "Inbox");
var sender = message[mail.MAIL_SENDER];

getMessageFor

getMessageFor(pUserTitle, pStoredMessageInfo, pFolderName): Map<any, any>

Returns the entire message associated with the ID you passed.

This function can only be called at the server.

Parameters

pUserTitle
string | number | boolean

The login name of the user.

pStoredMessageInfo
string | number | boolean

The ID of the message.

pFolderName
string | number | boolean

The name of the folder to be used.

Returns

Map<any, any>

The message as a map.

Throws

May throw an exception.

Example

// Get IDs of the messages in the Inbox
var messages = mail.getMessagesFor("c.rath", "Inbox");

// Get the entire message object for the last ID
// and retrieve the sender
var message = mail.getMessageFor("c.rath", messages[messages.length-1], "Inbox");
var sender = message[mail.MAIL_SENDER];

getMessages

getMessages(pFolderName): string[]

Retrieves the messages from the folder of the logged-in user.

This function can only be called at the server.

Parameters

pFolderName
string | number | boolean

The name of the folder to be used.

Returns

string[]

The identifiers of the messages

Throws

May throw an exception.

Example

var newmailids = mail.getMessages("Inbox");

getMessagesFor

getMessagesFor(pUserTitle, pFolderName, pCondition?): string[]

Retrieves the messages from the Inbox of a logged-in user.

This function can only be called at the server.

Parameters

pUserTitle
string | number | boolean

The login name of the user.

pFolderName
string | number | boolean

The name of the folder to be used.

pCondition?
any

Returns

string[]

The identifiers of the messages

Throws

May throw an exception.

Example

&lt;b&gt;Example 1 with search for timestamp&lt;/b&gt;
question.showMessage(date.longToDate(past, "dd.MM.yyyy HH:mm"));
var emails = mails.getMessagesFor("Lola Locker", "Inbox", ["received", "&lt;", past]);

&lt;b&gt;Example 2 with search for subject and timestamp&lt;/b&gt;
var past = eMath.subInt(vars.getString("$sys.date"), eMath.mulDec(10, datetime.ONE_DAY));
var dateTerm = ["received", "&lt;", past];
var subjectTerm = ["subject", "Attachment"];
var condition = { "and" : [dateTerm, subjectTerm] }
var emails = mail.getMessagesFor("Lola Locker", "Inbox", condition);

getNewMessages

getNewMessages(pUserTitle?): string[]

Retrieves the new messages from the user's Inbox.

This function can only be called at the server.

Parameters

pUserTitle?
string | number | boolean

The login name of the user.

Returns

string[]

The IDs of the new emails.

Throws

May throw an exception.

Example

var newmailids = mail.getNewMessages("docower");

getRepositoryAlias

getRepositoryAlias(): string

Returns the name of the repository alias for the mail repository.

Warning: This is not the name of the database where the mails are stored in the DB repository. This alias only describes the repository alias.

Within this repository alias, the DB is described in the key "Alias" (only for backend = DB).

Returns

string

The name of the alias. You can then retrieve the alias data model with project.getAliasModel().

Example

var alias = mail.getRepositoryAlias();
var aliasmodel = project.getAliasModel(alias);
var repository_table = aliasmodel[project.ALIAS_PROPERTIES]["table"];
question.showMessage(repository_table);

hasMail

hasMail(pIdentifier): boolean

Returns whether an email with a specified ID exists in the email repository.

Parameters

pIdentifier
string | number | boolean

The ID of the email.

Returns

boolean

'true' if a mail with the ID you passed exists.

Throws

May throw an exception.

Example

//pID is the ID of the history which contains the mail

var mail_id = db.cell([ "select MAIL_ID from HISTORY where HISTORYID = ? "
, [ [ pID, getSingleColumnType("HISTORY", "HISTORYID") ] ]
]);

if(mail.hasMail(mail_id) == true)
{
var email = mail.getMail(mail_id);
var attachments = mail.getAttachmentInfos(email);
//Code to get the infos of the attachment
}

hasNewMessages

hasNewMessages(pUserTitle?): boolean

Checks whether there are new messages in the Inbox of the user specified.

This function can only be called at the server.

Parameters

pUserTitle?
string | number | boolean

The login name of the user for whom to check for emails.

Returns

boolean

'true' if new emails exist.

Throws

May throw an exception.

Example

var newmails = mail.hasNewMessages("docower");

isValidMailAddress

isValidMailAddress(pMailAddress, pAllowLocalAddresses?): boolean

Checks if an email address is technically valid according to RFC 822 Standard. This validation only verifies the technical format - it does not check if the address exists or makes logical sense. By default, local addresses (e.g. localhost) are considered invalid.

Note that a technically valid email address may not necessarily be a valid recipient address or even desirable. For example, the following email addresses are technically valid but may not be practical:

  • ""@adito.de

  • adito@[::1]

  • "very.(),:;invalid input: '<'>[]".VERY."very@\ "very".unusual"@strange.example.com

Parameters

pMailAddress
string | number | boolean
pAllowLocalAddresses?
boolean

Determines if local addresses (e.g. localhost) should be accepted as valid

Returns

boolean

true if the address is technically valid, false otherwise

Throws

May throw an exception.


newMail

newMail(pMailTextRFC?, pMailFormat?): string

Creates a new email object.

Parameters

pMailTextRFC?
string | number | boolean

The contents of the email as RFC2822.

pMailFormat?
number

The format of the email. Currently, only mail.FORMAT_MIME is available.

Returns

string

The ID of the new email.

Throws

May throw an exception.

Example

var mailID = mail.newMail("This is a test email", mail.FORMAT_MIME);

newMailAs

newMailAs(pUserTitle, pMailTextRFC?, pMailFormat?): string

Creates a new email with the contents you passed.

Parameters

pUserTitle
string | number | boolean

The user name based on which you want to create the new email.

pMailTextRFC?
string | number | boolean

The contents of the email as RFC2822

pMailFormat?
number

The format of the email. Currently, only mail.FORMAT_MIME is available.

Returns

string

The ID of the new email.

Throws

May throw an exception.

Example

var mailID = mail.newMail("Lola Locker", "This is a test email", mail.FORMAT_MIME);

parseRFC

parseRFC(pRFC, pCharset?): Map<any, any>

Creates an ADITO email object from an email RFC file.

Parameters

pRFC
string | number | boolean

The email as a string.

pCharset?
string | number | boolean

The character set of the email.

Returns

Map<any, any>

The ADITO email object.

Throws

May throw an exception.

Example

// Parses an .eml file
var file = question.askQuestion("Which file?", question.QUESTION_FILECHOOSER, "");
var rfc = swing.doClientIntermediate(swing.CLIENTCMD_GETDATA, [file, util.DATA_TEXT]);
var mo = mail.parseRFC(rfc, "UTF-8");
question.showMessage(mo[mail.MAIL_SUBJECT]);

registerPrivateKey

registerPrivateKey(pEmail, pAlgorithm, pKey): void

Registers a private key for email SMIME.

If a key has already been registered, it will be overwritten.

Parameters

pEmail
string | number | boolean

The email address.

pAlgorithm
string | number | boolean

The algorithm to be used (DiffieHellmann, DSA, RSA, EC).

pKey
string | number | boolean

The Base64-encoded key.

Returns

void

Throws

May throw an exception.

Example

mail.registerPrivateKey("admin@domain.local", "RSA", key);

registerPublicKey

registerPublicKey(pEmail, pAlgorithm, pKey): void

Registers a public key for email SMIME.

If a key has already been registered, it will be overwritten.

Parameters

pEmail
string | number | boolean

The email address.

pAlgorithm
string | number | boolean

The algorithm to be used (DiffieHellmann, DSA, RSA, EC).

pKey
string | number | boolean

The Base64-encoded key.

Returns

void

Throws

May throw an exception.

Example

mail.registerPublicKey("admin@domain.local", "RSA", key);

resolveMail

resolveMail(pName): Map<any, any>

Retrieves a variable from the variable container, checks whether it is an email and returns it in processed form.

This method is used in the mailbridge. Within the mail processes, you can use the $local.mail variable which contains the ID of the email.

With mail.resolveMail(), the email can be processed.

Parameters

pName
string | number | boolean

The name of the variable searched for.

Returns

Map<any, any>

The email or 'null' if the variable does not exists, if it is no email or if another error occurred.

Throws

May throw an exception.

Example

var email = mail.resolveMail(vars.getString("$local.mail"));
var sender = email[mail.MAIL_SENDER];

resolveMailAsRFC

resolveMailAsRFC(pName): string

Retrieves a variable from the variable container, checks whether it is an email and returns it in RCF822 form.

This can be used as failback, when mail.resolveMail throws an error.

Parameters

pName
string | number | boolean

The name of the variable searched for.

Returns

string

The text or 'null' if the variable does not exists, if it is no email or if another error occurred.

Throws

May throw an exception.

Example

var rfc = mail.resolveMailAsRFC();

sendMail

sendMail(pMailID): number

Sends an email.

Parameters

pMailID
string | number | boolean

The ID of the email.

Returns

number

The number of emails sent.

Throws

May throw an exception.

Example

var sentCount = mail.sendMail("12");

sendMailAs

sendMailAs(pUserTitle, pMailID): number

Sends an email as the specified user.

Parameters

pUserTitle
string | number | boolean

The user name based on which you want to create the new email.

pMailID
string | number | boolean

The ID of the email.

Returns

number

The number of emails sent.

Throws

May throw an exception.

Example

var sentCount = mail.sendMailAs("Admin", "12");

sendMails

sendMails(pMailIDs): number

Sends emails.

Parameters

pMailIDs
string[]

The IDs of the emails.

Returns

number

The number of emails sent.

Throws

May throw an exception.

Example

var sentCount = mail.sendMails(["12", "13"]);

sendMailsAs

sendMailsAs(pUserTitle, pMailIDs): number

Sends emails as the specified user.

Parameters

pUserTitle
string | number | boolean

The user name based on which you want to create the new email.

pMailIDs
string[]

The IDs of the emails.

Returns

number

The number of emails sent.

Throws

May throw an exception.

Example

var sentCount = mail.sendMailAs("Admin", ["12", "13"]);

setHeader

setHeader(pMailID, pHeaderName, pHeaderContent): void

Sets the value of the desired header information.

Parameters

pMailID
string | number | boolean

The ID of the email.

pHeaderName
string | number | boolean

The name of the header information.

pHeaderContent
string | number | boolean

The contents of the header information.

Returns

void

Throws

May throw an exception.

Example

var email = mail.newMail();
mail.addHeader(email, "campaign", vars.getString("$image.campaignid"));

setReminderProcess()

setReminderProcess(pProcess): void

Sets the process informing the user about new emails.

Parameters

pProcess
string | number | boolean

The process to be executed.

Returns

void

Deprecated

Not supported anymore

Throws

May throw an exception.

Example

// in the autostart process
mail.setReminderProcess("lib_yougotmail"); The following local variables are available in the transferred process: - "$local.mailid" : the mailid

setSender

setSender(pMailID, pSender): void

Sets the sender of an email.

Parameters

pMailID
string | number | boolean

The ID of the email.

pSender
string | number | boolean

The sender to be set.

Returns

void

Throws

May throw an exception.

Example

var email = mail.newMail();
mail.setSender(email, "info@adito.de");

setSMimeEncryption

setSMimeEncryption(pMailID, pValue): void

Sets the flag that indicates whether the email should be encrypted.

Parameters

pMailID
string | number | boolean

The ID of the email.

pValue
boolean

'true' if the email is to be encrypted.

Returns

void

Throws

May throw an exception.

Example

mail.setSMimeEncryption("12345", true);

setSubject

setSubject(pMailID, pSubject, pEncoding?): void

Adds a subject to an email.

Parameters

pMailID
string | number | boolean

The ID of the email.

pSubject
string | number | boolean

The email subject.

pEncoding?
string | number | boolean

The encoding to be used for the subject.

Returns

void

Throws

May throw an exception.

Example

var email = mail.newMail();
mail.setSubject(email, "Life begins at the end of your comfort zone.", "UTF-8");

storeMail

storeMail(pMail): string

Saves an email to the repository.

Parameters

pMail
any

The email as a map, e.g. in the format returned by emails.getMail, emails.getMessage or in the RFC2822 format. The email (map) can only be used in unchanged form.

Returns

string

der Identifier der Mail

Throws

May throw an exception.

Example

var filePath = swing.askQuestion(translate.text("Bitte wählen Sie den Pfad zur .eml Datei die eingelesen werden soll"), swing.QUESTION_FILECHOOSER, null);
if (filePath != null)
{
var mailObj = mail.parseRFC(swing.doClientIntermediate(swing.CLIENTCMD_GETDATA, [filePath]));
mailObj[mail.MAIL_ID] = mail.storeMail(mailObj);
var sender = clearAddr(mailObj[mail.MAIL_SENDER]);
var recipients = mailObj[mail.MAIL_RECIPIENT].split(";").map(function (addr){ return clearAddr(addr); });

process.execute("supportmailbridge", {"sender":sender,"recipients":recipients,"mail":mailObj});
question.showMessage(translate.text("Die Datei wurde eingelesen und verarbeitet")); }

storeMessage

storeMessage(pStoredMessageInfo, pFolderName): string

Saves a message from a logged-in user in the repository.

This function can only be called at the server.

Parameters

pStoredMessageInfo
string | number | boolean

The ID of the email.

pFolderName
string | number | boolean

The name of the folder to be used.

Returns

string

The new identifier.

Throws

May throw an exception.

Example

// Get emails
var messages = mail.getMessagesFor("d.daenzer", "Inbox");
// Save the email in the repository
var mId = mail.storeMessage(messages[0], "Inbox");

// Check whether the email was saved in the repository
var hasM = mail.hasMail(mId);
question.showMessage(hasM);

storeMessageFor

storeMessageFor(pUserTitle, pStoredMessageInfo, pFolderName): string

Saves a message to the repository.

This function can only be called at the server.

Parameters

pUserTitle
string | number | boolean

The login name of the user.

pStoredMessageInfo
string | number | boolean

The ID of the email.

pFolderName
string | number | boolean

The name of the folder to be used.

Returns

string

The new identifier.

Throws

May throw an exception.

Example

// Get emails
var messages = mail.getMessagesFor("d.daenzer", "Inbox");
// Save the email in the repository

var mId = mail.storeMessageFor("d.daenzer", messages[0], "Inbox");
// Check whether the email was filed in the repository
var hasM = mail.hasMail(mId);
question.showMessage(hasM);

toRFC

toRFC(pMail): string

Generates text in RFC format from an email.

Parameters

pMail
any

The email object, for example as generated by mail.newMail() or the email as a map, e.g. from mail.getMail() / mail.getMessage().

Returns

string

The email in RFC format.

Throws

May throw an exception.

Example

var email = mail.toRFC(mail.resolveMail(vars.getString("$local.mail")));
fileIO.storeData("C:/MailBackups/mail.eml", email, util.DATA_TEXT, false);

Properties

AND

string

search criteria linked with AND


FLAG_ANSWERED

string

Flag: Emails answered


FLAG_DELETED

string

Flag: Emails deleted


FLAG_DRAFT

string

Flag: Draft


FLAG_FLAGGED

string

Flag: Emails flagged


FLAG_RECENT

string

Flag: Emails received (recent)


FLAG_SEEN

string

Flag: Emails read


FLAG_USER

string

Flag: User


FORMAT_MIME

number

format of the email that was passed: MIME


MAIL_ATTACHMENTCOUNT

string

MAIL_HTMLTEXT

string

MAIL_ID

string

MAIL_MESSAGEID

string

MAIL_OBJECT

string

MAIL_RECEIVEDATE

string

MAIL_RECIPIENT

string

MAIL_RECIPIENT_ADDRESSES

string

MAIL_SENDER

string

MAIL_SENDER_ADDRESSES

string

MAIL_SENTDATE

string

MAIL_SUBJECT

string

MAIL_TEXT

string

MAILBRIDGE_ERROR_FILTER

number

Mailbridge filtering error.


MAILBRIDGE_ERROR_GETMESSAGE

number

Mailbridge error while getting the email


MAILBRIDGE_ERROR_GETSIZE

number

Mailbridge error while determining the email size.


MAILBRIDGE_ERROR_LOG

number

Mailbridge error during the logging of processing.


MAILBRIDGE_ERROR_POSTHANDLING

number

Mailbridge error while postprocessing.


MAILBRIDGE_ERROR_PREHANDLING

number

Mailbridge error while preprocessing.


MAILBRIDGE_ERROR_PROCESS

number

Mailbridge error while executing the process.


MAILBRIDGE_ERROR_REPOSITORY_STORE

number

Mailbridge error while saving data to the repository.


MAILBRIDGE_ERROR_SERVERDELETE

number

Mailbridge error while deleting data from the server.


MAILBRIDGE_ERROR_SIZETOOBIG

number

Email is too big (mailbrige error)


MAILBRIDGE_ERROR_UNKNOWN

number

Unknown mailbridge error.


OR

string

search criteria linked with OR


RECIPIENT_BCC

string

RECIPIENT_BCC_ADDRESSES

string

RECIPIENT_CC

string

RECIPIENT_CC_ADDRESSES

string

RECIPIENT_TO

string

RECIPIENT_TO_ADDRESSES

string

TERM_BCC

string

Email search pattern: BCC Contents of BCC address must match the search criteria


TERM_BODY

string

Email search pattern: BODY The body text must contain the search criteria


TERM_CC

string

Email search pattern: CC Contents of CC address must match the search criteria


TERM_FLAG

string

Email search pattern: FLAG Search for flag; values: 'true' or 'false'


TERM_FROM

string

Email search pattern: FROM Contents of FROM address must match the search criteria


TERM_RECEIVED

string

Email search pattern: RECEIVED Search for date of reception; operators: =, invalid input: '<', >, invalid input: '<'=, >=, !=


TERM_SENT

string

Email search pattern: SENT Search for sending date; operators: =, invalid input: '<', >, invalid input: '<'=, >=, !=


TERM_SIZE

string

Email search pattern: SIZE Search for size; operators: =, invalid input: '<', >, >=, invalid input: '<'=, !=


TERM_SUBJECT

string

Email search pattern: SUBJECT The subject text must match the search criteria


TERM_TO

string

Email search pattern: TO Contents of TO address must match the search criteria