# EMailer
Inherits from: RHObject
EMailer is used to send e-mail and has a few advantages over the standard $Kernel.SMTPClient
approach:
- the port, host, and server defaults to the mail settings for notification (but can be changed);
- recipients can be a user ID, username, group ID, group name, e-mail address, RHUser instance, or List;
- adds CC to the message header (fixing a bug in
$Kernel.SMTPClient
); - BCC is supported;
- add multiple attachments (from the filesystem or CS repository);
- compose the mail body using markdown;
- automatically wrap the text in a formatted HTML message (can be customized);
- can be sent to multiple recipients or have each recipient recieve a personalized copy; and
- queueing (for deferred sending).
Mail can be sent in one line of code. For example:
$RHCore.EMailer.New(prgCtx) \
.addRecipients('Admin') \
.addCCRecipients('DefaultGroup') \
.setSubject('Server Restarted') \
.setBody('The Content Server instance was restarted.') \
.addAttachmentFile("C:/opentext/logs/abc.log") \
.renderMD() \
.setTemplate() \
.send()
See Sending E-Mail from OpenText Content Server (opens new window) for more information.
# Class Methods
# Inherited methods
# IsValidEmailAddress
function Boolean IsValidEmailAddress(Dynamic emailAddress)
# ListifyRecipients
function List ListifyRecipients(Object prgCtx, Dynamic items)
# New
function Dynamic New(Object prgCtx, String subject='', String body='', String mimeType='text/plain')
# Overrides:
New
in class RHObject
# Instance Methods
# Property Methods
Property methods can be accessed with the valueForKey
method.
attachmentsnode body bodymimetype classidentifier classname client clone context defaultfromsender defaultreplyto errorassoc fromaddress fullcgi hash host htmlify identityhashcode iterator methods okassoc port propertymethods rendermarkdown rendermd replyto reset send serialize server smtpconfiguration string subject template
# Inherited methods
assert cacheMethod cacheValueForKey callSuper checkError class classIdentifier className clone deserialize dict endTrans hash identityHashCode isAccessorMethod isCached isInstanceOf isProperty isPropertyMethod iterator methods pluck prepareForReuse propertyMethods removeFromCache reset resetCache respondsTo serialize setCacheValueForKey setValueForKey setValueForKeyPath setValues startTrans string super valueForKey valueForKeyPath
# addAttachmentFile
function Frame addAttachmentFile(String filePath, String displayName=File.GetName(filePath), String mimeType=$RHCore.FileUtils.GetMimeType(filePath, 'application/octet-stream'))
# addAttachmentNode
function Frame addAttachmentNode(Dynamic item, String displayName=Undefined)
Item can be a DataID, nickname, RHNode, or RHNodeVersion
# addBCCRecipients
function Frame addBCCRecipients(Dynamic recipients)
# addCCRecipients
function Frame addCCRecipients(Dynamic recipients)
# addRecipients
function Frame addRecipients(Dynamic recipients)
# attachmentsNode
function List attachmentsNode()
# body
function Dynamic body()
# bodyMimeType
function Dynamic bodyMimeType()
# client
function Frame client()
# context
function Frame context()
# defaultFromSender
function String defaultFromSender()
# defaultReplyTo
function String defaultFromSender()
# fromAddress
function Dynamic fromAddress()
# fullCGI
function String fullCGI()
# getEmailAddress
function String getEmailAddress(Dynamic item)
# host
function Dynamic host()
# htmlify
function Frame htmlify()
# port
function Dynamic port()
# queue
function Assoc queue(Boolean oneEmailPerRecipient=false)
# renderMarkdown
function Frame renderMarkdown()
# renderMD
function Frame renderMD()
# replyTo
function Dynamic replyTo()
# resetSubclass
function Void resetSubclass()
# Overrides:
resetSubclass
in class RHObject
# send
function Assoc send()
# sendOnce
function Frame sendOnce(Boolean sendOnce = true)
# server
function Dynamic server()
# setAttachmentsNode
function Frame setAttachmentsNode(List items)
# setBody
function Frame setBody(Dynamic body)
# setBodyMimeType
function Frame setBodyMimeType(Dynamic bodyMimeType)
# setContext
function Frame setContext(Frame context)
# setFromAddress
function Frame setFromAddress(Dynamic fromAddress)
# setHost
function Frame setHost(Dynamic host)
# setPort
function Frame setPort(Dynamic port)
# setRecipient
function Frame setRecipient(Dynamic recipient)
# setReplyTo
function Frame setReplyTo(Dynamic replyTo)
# setServer
function Frame setServer(Dynamic server)
# setSubject
function Frame setSubject(Dynamic subject)
# setTemplate
function Frame setTemplate(Dynamic template="rhcore/email/email.html")
# setValueToTaskDataForKey
function Dynamic setValueToTaskDataForKey(Dynamic value, String key)
This writes a value to the fTaskData
Assoc, which is passed to the mail queue.
# Parameters
value
- The value to add to thetaskdata
.key
- The key.
# Returns
Returns
this
.
# subject
function Dynamic subject()
# template
function Dynamic template()