This custom object sends an email through the API. An example call from Groovy would be:
Email.send("from-addr@axeda.com","to-axeda@axeda.com","Test Subject","This is the body of the email");
Name: EmailTest
Type: Action
Description: (type your own)
Source Code:
import groovy.xml.MarkupBuilder
// initialize our XML response
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
def address = parameters.address
def phrase = parameters.phrase
def subject = "Email Sent Successfully! Phrase: ${phrase}"
def body = "<html><body><H2>If you can read this, then the email was correctly sent with the Phrase ${phrase}</H2><br/><img src=\"http://albc-usa.org/images/amj2.jpg\" border=\"0\"/></body></html>"
try {
// this is all you need to do!
com.axeda.drm.sdk.contact.Email.send("from-${address}",address,subject,body,"text/html")
xml.Email {
xml.Address(address)
xml.Subject(subject)
xml.body(body)
}
} catch (Exception e) {
StringWriter logStringWriter = new StringWriter();
PrintWriter logPrintWriter = new PrintWriter(logStringWriter)
e.printStackTrace(logPrintWriter)
logger.error("Exception occurred in FunWithMath.groovy: ${logStringWriter.toString()}")
xml.error() {
faultcode ("Groovy Exception")
faultstring(e.getMessage())
}
}
return ["Content-Type": "application/xml","Content":writer.toString()]Parameters: None
Parameters: Three parameters:
Variable name |
Display name |
Username |
(REQUIRED) The name of the calling user |
address |
(REQUIRED) The email address to send an email |
phrase |
(REQUIRED) The phrase (or body) to include in the email |