Send an Email using CFScript

<cfscript>  
	savecontent variable="mailBody"{   
		writeOutput('<h1>Hello!</h1><p>Tada it works.</p>');  
	}    
	/* create mailer service */  
	mailerService = new mail();    
	/* set mail attributes using implicit setters provided */  
	mailerService.setTo('TO@somedomain.com'); 
	mailerService.setFrom('FROM@somedomain.com');  
	mailerService.setSubject('YOUR SUBJECT');  
	mailerService.setType("html");  
	/* add mailparams */  
	mailerService.addParam(file=expandpath(form.attachment),type="text/plain",remove=false);  
	/* send mail using send(). Attribute values specified in an end action like "send" will not persist after the action is performed */  
	mailerService.send(body=mailBody);  writeoutput("<h3>Thank you</h3>" & "<p>Thank you, " & mailfrom & "<br>" & "Your message, " & subject & ", has been sent to " & mailto & "</p>");
</cfscript>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s