Created
April 8, 2016 17:26
-
-
Save jeaguilar/d8bc801ab7a744af5ee782a6eddf4477 to your computer and use it in GitHub Desktop.
Sendgrid CFML sample using sendgrid-java.jar and tested on Lucee 4.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
try { | |
SendGrid = CreateObject("java", "com.sendgrid.SendGrid", expandPath("sendgrid-java.jar")).init('<API KEY>'); | |
Email = CreateObject("java", "com.sendgrid.SendGrid$Email", expandPath("sendgrid-java.jar")); | |
Email.addTo("<TO ADDRESS>"); | |
Email.setFrom("<FROM ADDRESS>"); | |
Email.setSubject("Hello World, #getTickCount()#"); | |
Email.setHtml("<p>My <strong>first</strong> email with SendGrid Java!</p>"); | |
javaFile = createObject( 'java', 'java.io.File' ).init( '<FILE LOCATION>' ); | |
Email.addAttachment('<FILE NAME>', javaFile); | |
javaResponse = SendGrid.send(Email); | |
objResponse = {}; | |
objResponse.Message = javaResponse.getMessage() ?: ""; | |
objResponse.Status = javaResponse.getStatus() ?: ""; | |
objResponse.Code = javaResponse.getCode() ?: ""; | |
writeDump(objResponse); | |
} | |
catch (Any excpt) { | |
writeDump(excpt); | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment