email_send_noprofile Function

Syntax

P Result = email_send_noprofile(P pSmtpSettings ,P pMessageSettings [,C secureMode [,L autoWrap [,L flagUseDotNetLibrary ]]])

Arguments

pSmtpSettingsPointer

The SMTP settings. The following settings can be set:

smtp_serverCharacter

The address of the smtp server. e.g.'smtp.gmail.com'

smtp_usernameCharacter

Your email account user name, e.g. 'fred' or '[email protected]'

smtp_passwordCharacter

Your email account password, e.g. 'mysecretpassword'

smtp_portNumeric

The port e.g. 465. This depends on the server. For example with Gmail, the port is often 587

pMessageSettingsPointer

An object with these properties (some properties are optional):

fromCharacter

Required. The email address of the sender

send_toCharacter

Required. A comma delimited list of email addresses

messageCharacter

The plain text version of the message. If html_message is not specified, message is required.

html_messageCharacter

The html version of the message. Required if message is not set.

subjectCharacter

The message subject, in plain text.

from_aliasCharacter

The friendly/display name of the sender

attachmentsCharacter

A comma delimited list of file attachments.

If the file name(s) contain a comma, you can escape the comma using {comma}. For example:

file1{comma}description.txt,file1.txt
ccCharacter

A comma delimited list of email addresses to "CC".

bccCharacter

A comma delimited list of email addresses to "BCC".

lRelatedLogical

.t. or .f.

ReturnReceiptLogical

.t. or .f. indicating whether or not a return receipt is desired.

headersCharacter

Default = "". Optional email headers. Email headers are specified as a CR-LF delimited list of colon separated name-value pairs. Headers can be one of the standard mail headers or a user-defined header. Prefix user-defined headers with "X-".

dim headers as c =<<%str%
Reply-To: [email protected]
X-company: Example Co
X-campaign: Spring Launch
%str%

See RFC 822 to learn more about message headers.

The support of an email header is dependent on the email client. Some email clients may not support the header(s) you include in the message.
secureModeCharacter

Mode to use for secure connections. Can be blank, 'SSL', or 'TLS'.

autoWrapLogical

Word-wrapping mode; does not apply if flagUseDotNetLibrary is .t., and irrelevant for HTML mail; default is .T.

flagUseDotNetLibraryLogical

By default, the e-mail is sent using Alpha Anywhere's internal 'sockets' object. Since V11 has access to the full Microsoft .NET Framework, you can also send the e-mail using methods in the .NET Framework by setting this value to .T.; default is .F.

Returns

pFlagPointer

Returns an object with two properties:

errorLogical

Either .t. or .f.

errorTextCharacter

Description of the error if any occurred.

Description

Sends an e-mail message. All e-mail settings are passed in. Does not use an Alpha Anywhere e-mail profile.

Discussion

The EMAIL_SEND_NOPROFILE() function sends an email via SMTP.

This function uses the EMAIL_SMTP_OPEN(), EMAIL_SMTP_SEND(), and EMAIL_SMTP_CLOSE() functions internally. Refer to EMAIL_SMTP_SEND() for additional examples for setting other message properties, such as headers and attachments.

dim message as p
message.from = "[email protected]"
message.from_alias = "Jane Doe"
message.send_to = "[email protected]"
message.subject = "Welcome to Acme Inc!"
message.message = "The Acme family is excited to see you join."

dim smtpSettings as p
smtpSettings.smtp_server = "mail.acmeinc.com"
smtpSettings.smtp_username = "username"
smtpSettings.smtp_password = "password"
smtpSettings.smtp_port = 25

dim result as p
result = email_send_noprofile(smtpSettings,message,"")

? result
= error = .F.
errorText = ""

Including HTML Encoded Text in the Subject

You can include HTML encoded text in the email subject. For example, the following example shows how to include Japanese text in the subject as HTML encoded characters:

dim message as p
message.from = "[email protected]"
message.from_alias = "Jane Doe"
message.send_to = "[email protected]"
message.subject = "&#12513;&#12540;&#12523;&#12398;&#20214;&#21517;"
message.message = "The Acme family is excited to see you join."

dim smtpSettings as p
smtpSettings.smtp_server = "mail.acmeinc.com"
smtpSettings.smtp_username = "username"
smtpSettings.smtp_password = "password"
smtpSettings.smtp_port = 25

dim result as p
result = email_send_noprofile(smtpSettings,message,"")

See Also