dbASPdbSendMail | dbMail

Send SMTP mail using CDONTS.NewMail object. The E-mail parameters are set in the dbMail property. The E-mail body can be either plain text or the template file generated by dbMagicLayout. ASPdbSendMail supports multiple recipients and attached files as well as Mailing list stored in various DBs.

Property & Method Syntax

Obj.ASPdbSendMail

dbMail = "(|~+)From | To | Cc | Bcc | Subject | Body | Format | importance(0=low 1=normal 2=high) | Mbase | Mloc | Mattach | name=value,name=value2... | Batch | IgnoreError | BufferSize | Visual"

Parameters

Default Value

Description

From   MailObj.From address
To   MailObj.To - This parameter has 3 formats -
  1. Address
  2. Address1; Address2; Address3
  3. SELECT AddressField FROM Table WHERE... ORDER BY .... ~ Connect*String
  • Delimiter of #2 has to be (;) therefore (;) cannot be the group delimiter. Group delimiter defaults to (|).
  • Format #3 extract the address list from a database and optionally, a connectstring can be specified. That means, the E-Mail address DB can be at a difference data source.
  • If the first 7 characters is "SELECT " (Space at the end), then format #3 will be used. Otherwise, format #1 and #2 will be used.
Cc   MailObj.Cc address
Bcc   MailObj.Bcc address
Subject   Mail.Obj.Subject text.
Body   MailObj.Body has 2 formats -
  1. Plain Text. No text processing will be done.
  2. Tmp=Filename. The filename is the name of a template file. This template file can be the same file used in display and is processed the same way as ASPdbSendTemplate. If this option is used the Mail format will be forced to be HTML type.
Format 1  0=HTML 1=Plain Text. For TMP=File Format will be set to 0.
Importance 1  0=low 1=normal 2=high
Content Base & 
Content Location
  Content Base and Location are used to retrieve images files.
e.g. Content Base="http://www.myserver.com/Content Location=Directory/
Images will be prefixed as -> http://www.myserver.com/Dir/ImageFile.gif
Attach   MailObj.AttachFile -> Filename, Caption, Encode_Method,...repeat...
Encode method defaults to UUENCODE (0). Use (1) for Base_64 encoding.
Each file attached requires the above 3 parameters. Parameters cannot be skipped. Only Encode can be left as blank indicating a default of 0.
If Caption file name has no extension, a 'dat' extension will be attached. 
e.g. The following example attaches 2 files. TMP.dbMail="(|,)frank@aspdb.com |kwongf@eaglequest.com |||ASPdbSendMail|  tmp=e:\Vdata\Article\ASPDB2k-2b.tmp |0|0|||e:\vdata\article\temp.asp,TTT.txt,, e:\vdata\article\Stock.csv, Stock.csv,0"
Custom Headers    Send custom headers via -> HeaderName1=Value1, HeaderName2=Value2....
Batch False If this value is true, mail will be send to multiple addresses in a batch mode via Address1; Address2... Otherwise, a new NewMail object will be generated to send mail to each individual address.
Ignore Error True Set to false will cause the mail sending action to quit.
BufferSize 512 This buffer is the buffer size of the addresses like addr1;addr2;addr3. Leave it at 512 to be save !
Visual False Set to true will cause the mail sending action of each address to the browser

Example #1 -  Sending a complicated template

<%
dim item
'.......... Order Export variables

Set Order=Server.CreateObject("ASP.DB")
Order.dbQuickProps="1;NWIND;;Grid;;;;ACCESS;1000;;;false;false"
Order.dbSQL="SELECT OrderID, CustomerID FROM Orders where OrderID = 10248"
Order.dbExportFlds="0,1"
Order.ASPDB

'.......... Order selected (Ship info)
Set Order1=Server.CreateObject("ASP.DB")
Order1.dbQuickProps="2;NWIND;;Grid;;;;ACCESS;1000;;;false;false"
Order1.dbSQL="SELECT * FROM Orders WHERE OrderID = " & session("aspdb_1_OrderID")
Order1.dbDisplayLookUpList="(;|)CustomerID||SELECT CustomerID, CompanyName FROM Customers; EmployeeID||SELECT EmployeeID, FirstName & ' ' & Lastname as Name FROM Employees"
Order1.dbOptions="ExportMagic=true"
Order1.dbBlankText="&nbsp;"
Order1.dbExportFlds="0,1,2,3,4,5,(6),(7),8,9,10,11,12,13"
Order1.ASPDB

'.......... Order details (Products in Order)
Set Detail=Server.CreateObject("Asp.DB")
Detail.dbQuickProps="3;NWIND;;Grid;;;;ACCESS;1000;;;false;false"
Detail.dbSQL="SELECT ProductID, UnitPrice, Quantity, Discount, UnitPrice * Quantity * (1-Discount) as ExtPrice FROM [Order Details] WHERE OrderID = " & session("aspdb_1_OrderID")
Detail.dbMagicCell="ProductID,align=right; UnitPrice,align=right,format=[currency]; Quantity,align=right; Discount,align=right,format=[##0%],,,100; ExtPrice,align=right,format=[currency]"
Detail.dbAggColumns="SUM,4"
Detail.dbMagicLayout="1;GRID"
Detail.ASPDB

'.......... Customer info (Bill to)
Set Customer=Server.CreateObject("Asp.DB")
Customer.dbQuickProps="4;NWIND;;Grid;;;;ACCESS;1000;;;false;false"
Customer.dbSQL="SELECT * FROM Customers WHERE CustomerID = '" & session("aspdb_1_CustomerID") & "'"
Customer.dbBlankText="&nbsp;"
Customer.dbExportFlds="1,2,3,4,5,6,7,8"
Customer.ASPDB

set TMP=Server.CreateObject("ASP.DB")
TMP.dbMail="(|,)frank@aspdb.com |kwongf@eaglequest.com |||ASPdbSendMail|tmp=f:\Vdata\Article\ASPDB2k-2b.tmp|0|0|||||||512|True"
TMP.aspDBSendMail    'Send The output w/o display
%>

Example #1 - Template File (f:\Vdata\Article\ASPDB2k-2b.tmp)

<BODY bgColor=#c9b49a>
<CENTER>
<H3>This Report is sent directly from ASPdb2000 using ASPdbSendMail</H3>
<h3>NorthWind Report on [[Today:MM/DD/YY]]</h3>

<table cellspacing='0' cellpadding='2' rules='all' bordercolor='#000000' border='1' style='background-color: #FFFFFF; border-collapse: collapse; border-color: Black' Cellpadding=2 Cellspacing=2>
<TR><TH Align=right>Sales Person</TH><TD>[[aspdb_2_EmployeeID:S]]</TD></TR>

<TR><TH Align=right>Bill To</TH>
<TD>[[aspdb_4_ContactName:S]] ([[aspdb_4_ContactTitle:S]])<BR>
[[aspdb_4_Address:S]]<BR>[[aspdb_4_City:S]], [[aspdb_4_Region:S]] [[aspdb_4_Region:SX:,]] [[aspdb_4_PostalCode:S]] [[aspdb_4_PostalCode:SX:,]] [[aspdb_4_Country:S]]</TD></TR>

<TR><TH Align=right>Ship To</TH>
<TD>[[aspdb_2_ShipName:S]]<BR>[[aspdb_2_ShipAddress:S]]<BR> [[aspdb_2_ShipCity:S]], [[aspdb_2_ShipRegion:S]] [[aspdb_2_ShipRegion:SX:,]] [[aspdb_2_ShipPostalCode:S]] [[aspdb_2_ShipPostalCode:SX:,]] [[aspdb_2_ShipCountry:S]]</TD></TR>

<TR><TH Align=right>Ship Via</TH><TD>
<INPUT TYPE="Checkbox" [[aspdb_2_ShipVia:SC:1]]>Speedy
<INPUT TYPE="Checkbox" [[aspdb_2_ShipVia:SC:2]]>United
<INPUT TYPE="Checkbox" [[aspdb_2_ShipVia:SC:3]]>Federal </TD></TR>

<TR><TH Align=right>Order Date</TH><TD>[[aspdb_2_OrderDate:S]]</TD></TR>
<TR><TH Align=right>Required Date</TH><TD>[[aspdb_2_RequiredDate:S]]</TD></TR>
<TR><TH Align=right>Shipped Date</TH><TD>[[aspdb_2_ShippedDate:S]]</TD></TR>

<TR><TH Align=right>Order Details</TH><TD>[[aspdb_Layout_3_1:S]]</TD></TR>
<TR><TH Align=right>Subtotal</TH><TD>[[SV_SUM_3_4:S:$###.#0]]</TD></TR>
<TR><TH Align=right>Freight</TH><TD>[[aspdb_2_Freight:S:$###.#0]]</TD></TR>
<TR><TH Align=right>Total</TH><TD><B> [[aspdbSUM:$###,###.#0:aspdb_2_Freight,SV_SUM_3_4]] </B></TD></TR>

</TABLE></CENTER>

Example #1 - Browser Output

Example #2 -  E-mail with attachments

<%
set TMP=Server.CreateObject("ASP.DB")
TMP.dbMail = "(|,)frank@aspdb.com|kwongf@eaglequest.com ||| ASPdbSendMail|Hello ! There are two files attached. |0|0||| e:\vdata\article\temp.asp,TTT.txt ,, e:\vdata\article\stock.csv,Stock.csv,0"
TMP.aspDBSendMail
%>
 

 
Example #3 -  E-mail via User Inputs / DB / template

....................... Sending via User input<BR>
<%
Set TMP = server.CreateObject("ASP.DB")
TMP.dbMail = "(|~+)frank@aspdb.com|frank@beaconsfieldgroup.com;frank@aspdb.com;frank@usintertech.com|||Test Email|Hello this is a Body|||||||false||64|True"
TMP.aspDBSendMail
%>

<HR> .........................Sending via DB using field (0) as mail address <BR>

<%
Set TMP = server.CreateObject("ASP.DB")
TMP.dbMail = "(|~+)frank@beaconsfieldgroup.com|SELECT address FROM Table1~DSN=EMAIL|||Test Email|Hello this is a Body|||||||false||64|True"
TMP.aspDBSendMail
%>

<HR> .........................Sending via DB and a tmp file Body specifying Address as the field<BR>
<%
Set TMP = server.CreateObject("ASP.DB")
TMP.dbMail = "(|~+)frank@beaconsfieldgroup.com|SELECT * FROM Table1 ~DSN=EMAIL~Address|||Subject is Test Email|tmp=E:\VDATA\EMAIL.TMP|||||||false||1|True"
TMP.aspDBSendMail
%>

Template file=E:\VDATA\EMAIL.TMP
Mail message = Hello [[Firstname:F]] [[Lastname:F]]


Notes

The requirement of the SendMail is the installation of the SMTP server that comes with Option Pack 4. Use your Internet Service Manager to verify that the SMTP server is running before you execute ASPdbSendMail.