Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Email

PHPrunner32x32     ASPRunner.NET manual

Send an email with an attachment from the database

Scroll Prev Next More


To send an email with attachments stored in a database field, use the following code in events like BeforeAdd/AfterAdd/BeforeEdit/AfterEdit.


Make sure to replace "Field that stores attachments" with the actual field name.


Note: Attachments will only work when you selected "Use custom mailer server settings" under "Email settings".


Note: Change red values to match your project.


msg =""
set tmpDict = CreateObject("Scripting.Dictionary")
if values("Field that stores attachments")<>"" then
  set fileArray = CreateObject("Scripting.Dictionary")
  set fileArray = my_json_decode(values("Field that stores attachments"))
  set attachments = CreateObject("Scripting.Dictionary")
  for i = 0 to asp_count(fileArray)-1
     attachments(i) = getabspath(fileArray(i)("name"))
  set tmpDict("attachments") = attachments
end if
msg = msg & "Make: " & values("Make") & vbcrlf
msg = msg & "Model: " & values("Model") & vbcrlf
tmpDict("to")="[email protected]"
tmpDict("subject")="Sample subject"
set ret=runner_mail(tmpDict)
if not ret("mailed") then
   response.write ret("message")
end if

See also:

Send simple email

runner_mail function

How to email selected records as separate PDF files

Email selected records

Send an email to all users

Send an email to selected users

Send an email with updated fields only