Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created January 30, 2014 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ableasdale/8716999 to your computer and use it in GitHub Desktop.
Save ableasdale/8716999 to your computer and use it in GitHub Desktop.
MarkLogic - Amped email
xquery version "1.0-ml";
module namespace amped = "http://marklogic.com/kb/amp";
declare variable $SUBJECT as xs:string := "Email from a Module";
declare variable $FROM-NAME as xs:string := "MarkLogic (AMPED)";
declare variable $FROM-EMAIL as xs:string := "marklogic@example.com";
declare variable $TO-NAME as xs:string := "Example Recipient";
declare variable $TO-EMAIL as xs:string := "recipient@example.com";
declare variable $EMAIL-BODY as element(div) := <div>This email was sent from an <strong>amped</strong> function</div>;
declare function amped:email() {
xdmp:email(
<em:Message
xmlns:em="URN:ietf:params:email-xml:"
xmlns:rf="URN:ietf:params:rfc822:">
<rf:subject>{$SUBJECT}</rf:subject>
<rf:from>
<em:Address>
<em:name>{$FROM-NAME}</em:name>
<em:adrs>{$FROM-EMAIL}</em:adrs>
</em:Address>
</rf:from>
<rf:to>
<em:Address>
<em:name>{$TO-NAME}</em:name>
<em:adrs>{$TO-EMAIL}</em:adrs>
</em:Address>
</rf:to>
<em:content>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test HTML message</title>
</head>
<body>
{$EMAIL-BODY}
</body>
</html>
</em:content>
</em:Message>)};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment