Show/Hide Toolbars

Navigation: Advanced topics > Programming topics

ASPrunnerPro32x32     ASPRunnerPro manual


Function runner_mail

Scroll Prev Next More

 

Description

 

Function runner_mail is ASPRunnerPro wrapper for email function.

 
To use it you need to setup email parameters like From, SMTP server etc in Email settings.

 

Syntax

runner_mail(params)

 

Arguments

 

params - Scripting.Dictionary object with input parameters. The following parameters are supported:

 

from - sender email address. If none specified an email address from the wizard will be used.

 

fromName - sender name.

 

to - receiver 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.

 

body - plain text message body.

 

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

 

charset - html message charset. If none specified the default website charset will be used.

 

attachments - attachments description.

 

Return value

 

Array with the following keys:

 

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

 

message: 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