Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics

PHPrunner32x32     ASPRunner.NET manual


Function runner_mail

Scroll Prev Next More

Description

The runner_mail function is a wrapper for the mail() function in ASPRunner.NET.

 

To use it, you need to set up email parameters (From, SMTP server, SMTP server port, SMTP server username, SMTP server password) in the Email settings.

Syntax

runner_mail(params)

Arguments

params

an array with input parameters. The following parameters are supported:

Email parameters

from

the sender's email address. If none is specified, an email address from the Email settings is used.

fromName

the sender's name.

to

the receiver's email address.

cc

email addresses of secondary recipients.

bcc

email addresses of recipients whose addresses are not to be revealed to other recipients of the message.

replyTo

the reply email address.

priority

the message priority (use '1' for urgent, '2' - high, '3' - normal).

body

the plain text message body.

htmlbody

the html message body (do not use the 'body' parameter in this case).

charset

the html message charset. If none is specified, the default website charset is used.

attachments

the description of the attachments. The 'path' (a path to the attachment) is required. Other parameters are optional: 'name' overrides the attachment name, 'encoding' sets the file encoding, 'type' sets the MIME type.

Return value

An array with the following keys:

 

mailed: (true or false) indicates whether the email was sent or not.

message: an error message in case the email was not sent.

Examples

Send simple email

' do not forget to setup email parameters like From, SMTP server etc
' on 'Security->User login settings' dialog
set params = CreateObject("Scripting.Dictionary")
params("to")="[email protected]"
params("subject")="Sample subject"
params("body")="message"
runner_mail(params)

Send HTML email

set params = CreateObject("Scripting.Dictionary")
params("to")="[email protected]"
params("subject")="Sample subject"
params("htmlbody")="<body><html><p>Hello<br>Best regards</p></body></html>"
params("charset")="UTF-8"
runner_mail(params)

Example with error handling

set params = CreateObject("Scripting.Dictionary")
params("to")="[email protected]"
params("subject")="Sample subject"
params("body")="Hello there" & vbcrlf & "Best regards"
set result = runner_mail(params)
if not result("mailed") then
 response.write result("message")
 response.flush
end if

Send email with BCC and CC fields

set params = CreateObject("Scripting.Dictionary")
params("to")="[email protected]"
params("cc")="[email protected]"
params("bcc")="[email protected]"
params("subject")="Sample subject"
params("body")="message"
runner_mail(params)

Send email with From and FromName fields

set params = CreateObject("Scripting.Dictionary")
params("to")="[email protected],[email protected],[email protected]"
params("subject")="Sample subject"
params("body")="message"
params("from")="[email protected]"
params("fromName")="Bill Gates"
runner_mail(params)

Send email to multiple recipients

set params = CreateObject("Scripting.Dictionary")
params("to")="[email protected],[email protected],[email protected]"
params("subject")="Sample subject"
params("body")="message"
runner_mail(params)

Send email with attachments

dim tmpDict
set tmpDict = CreateObject("Scripting.Dictionary")
tmpDict("to")="[email protected]"
tmpDict("subject")="Sample subject"
tmpDict("body")="Hello there" & vbcrlf & "Best regards"
set attachments = CreateObject("Scripting.Dictionary")
attachments(0) = getabspath("files/1.jpg")
attachments(1) = getabspath("files/2.jpg")
set tmpDict("attachments") = attachments
set ret=runner_mail(tmpDict)
if not ret("mailed") then
    response.write ret("message")
end if

Send email with new record data. Use this code in the After Add event.

dim tmpDict, msg, ret
msg =""
msg = msg & "Name : " & values("name") & vbcrlf
msg = msg & "Email : " & values("email") & vbcrlf
msg = msg & "Age : " & values("age") & vbcrlf
set tmpDict = CreateObject("Scripting.Dictionary")
tmpDict("to")="[email protected]"
tmpDict("subject")="The new record was added: "
tmpDict("body")=msg
set ret=runner_mail(tmpDict)
if not ret("mailed") then
    response.write ret("message")
end if

See also:

Email settings

Events: AfterAdd

runner_sms function

Event editor

About predefined actions

Dialog API