EMAIL_SEND Function
Syntax
Arguments
- send_toCharacter
One or more comma delimited addresses.
- subjectCharacter
The subject of the message.
- messageCharacter
The contents of the message.
- attachmentsCharacter
A ";", comma, or CR-LF delimited list of filenames to attach to the message. If multiple attachments are specified, Alpha Anywhere will automatically zip the attachments into a single file. Any file type can be attached.
- ccCharacter
One or more comma delimited addresses.
- bccCharacter
One or more comma delimited addresses.
- store_in_outboxLogical
.T. = Alpha Anywhere stores a copy of the message in the Alpha Anywhere outbox (typically A_EMAIL.DBF in the program folder). .F. = Copy not saved.
When sending email from the Server only version of the Application Server, set this value to .F.- text_typeCharacter
Default = "" (plain text). "" (Null) = plain text email, "HTML" = HTML email.
- html_messageCharacter
The contents of the message in HTML format.
- profileCharacter
The name of your email profile as found on the View > Settings > Email > Profiles tab.
When sending email from an ISP's server, you must specify your profile.- zip_attachLogical
Default = .T. .T. = Attachments are zipped into a single file. .F. = Attachments are individual files.
- lSilentLogical
Default = .F. Allows you to trap errors using the Xbasic ON ERROR GOTO command. .T. = Error trapping on. .F. = Error trapping off.
- returnReceiptLogical
Default = .F. Allows you to specify a request a return receipt.
Returns
- ResultNumeric
Result is 0 if the email was not sent, and 1 if the email was sent.
Description
Sends an e-mail using the built-in, Alpha Anywhere e-mail feature. Set text_type to "html" for HTML email. If lSilent = .T., email_send will throw an error rather than show a message box.
EMAIL_SEND() sends an email message using Alpha Anywhere's built-in email features. It does not require a third party email client (such as Eudora, or Outlook.)
If Text_Type is "HTML" and Message and HTML_Message are both specified, Message is treated as the plain text version and HTML_Message is treated as the HTML version. In this case, both the plain text version and the HTML version are sent together in the same email. Email clients that support HTML text will see the HTML version and those that do not will see the plain text version.
If HTML_Message is not specified and Text_Type is "HTML," message is treated as the HTML text.
Example
Sends an email message using Alpha Anywhere's internal email facility. A copy of the message is stored in the user's AlphaAnywhere outbox.
body =<<%a% Just wanted to let you know that we really enjoy using Alpha Anywhere. %a% email_send("[email protected]","Thanks",body,"","","",.T.)
The Silent option is useful for Xbasic programmers who are using the email_send() function in a loop where they want to prevent the standard Alpha Anywhere error messages from popping up when an error (such as a bad email address) in encountered. Instead, they want to write their own error handler for this condition. For example:
Dim tbl as P Dim ITbl as P Tbl = table.open("customers") Query.filter = "balance> 1000000" Query.order = "recno() " ITbl = tbl.query_create() Tbl.fetch_first() While .not. tbl.fetch_eof() ON ERROR GOTO BAD_EMAIL
Fill in all of the arguments for EMAIL_SEND() and set the Silent parameter to .T..
Email_send("...", .t.) ON ERROR GOTO 0 'turn error handler off Tbl.fetch_next() End While Tbl.close() 'end the main script here so that it does not continue into the error handler End BAD_EMAIL: 'put you own error handling code here RESUME NEXT 'causes Alpha Anywhere to resume on the line after email_send() end
See Also