Last active
October 8, 2015 20:04
-
-
Save howellcc/cad546f6e1bab262f6f7 to your computer and use it in GitHub Desktop.
CFMail in cfscript
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
if(IsDefined("form.mailto") and isValid('email',form.mailTo)) { | |
mailSvc = new mail(); | |
mailSvc.setTo(form.mailto) | |
.setFrom(form.mailFrom) | |
.setSubject(form.subject) | |
.setType("html"); | |
/* add mailparams */ | |
mailSvc.addParam(file=expandpath(form.attachment),type="text/plain",remove=false); | |
savecontent variable="mailBody"{ | |
WriteOutput("<html><body><p>" | |
& "#rc.formBean.getValue('formName')# - Submission at #dateTimeFormat(now(),"medium")#" | |
& "<br><br>" | |
& "First Name: #rc.formSubmissionBean.getValue('firstName')#<br/>" | |
); | |
} | |
/* send mail using send(). Attribute values specified in an end action like "send" will not persist after the action is performed */ | |
mailSvc.send(body=mailBody); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment