Implement the e-mail sending function

I have a few questions
Among them
For example, let’s say you want to develop a simple booking system.
If you want to send an approval email after receiving a reservation
Can you implement the e-mail sending function from qodly?

Hey Caos,

You can use the Email object to create, send and receive mails using SMTP, IMAP or POP3 servers.

you can find more informations in this link

Hi caos,

You can also easily implement a third party mail service like sendGrid.
Here is a quick code snippet that I use to send an email to one recipient with one optional attachment.
This code can be placed in a sendGrid class to instantiate whenever you need.

// Documentation on
// sendGrid.4qs class
	property host : string
	property apiKey : string
	this.apiKey = PASTE_HERE_YOU_API_KEY = ""

function sendMail(to: object, subject : string, message : string, attachmentContent: variant, attachmentName : string)
	var content64 : string
	var headers, opts, data : object
	var request : 4D.HTTPRequest
	headers = newObject("Authorization", "Bearer "+this.apiKey, "Content-Type", "application/json")
	data = {}
	data.personalizations = []
	data.personalizations.push({to: [{email:, name: to.fullname}]})
	data.from = {email: "", name: "John Doe"}
	data.subject = subject
	data.content = []
	data.content.push({type: "text/html", value: message})
	if ((attachmentContent != null) && (attachmentContent != "") && (attachmentName != ""))
		data.attachments = []
		base64Encode(attachmentContent, content64)
		data.attachments.push({content: content64, type: "text/plain",filename: attachmentName})
	opts = {method: "POST", headers: headers, body: data}
	request ="/mail/send", opts)
	if (request.response.status != 202)
		if (undefined(request.response.body.errors[0].message))
			throw(1, request.response.statusText)
			throw(1, request.response.body.errors[0].message)
	webForm.setMessage("Email sent to " + + ". Check your mailbox!")


var mailer : cs.sendGrid
mailer =
mailer.sendMail({email: "", fullname: "John Smith"}, "My email title", "My email body text", attachmentContent, "attachmentFilename.ext")

Thank you for your great suggestion

APIs expand the possibilities, don’t they?

I would like to try

1 Like

Yes APIs expand a lot. And this is valid for much more than emails.
You can try this with a Qodly sandbox, there is no feature limitation. Have fun.