Send

Syntax1

Description

Sends a message to a window so that it is executed immediately.

Syntax

Send ( handle, message#, lowword, long )

Argument

Description

handle

A long whose value is the system handle of a window (that you have created in PowerBuilder or another application) to which you want to send a message.

message#

An UnsignedInteger whose value is the system message number of the message you want to send.

lowword

A long whose value is the integer value of the message. If this argument is not used by the message, enter 0.

long

The long value of the message or a string.


Return value

Longptr.

Returns the value returned by SendMessage in Windows if it succeeds and -1 if an error occurs. If any argument's value is null, Send returns null.

Usage

PowerBuilder's Send function sends the message identified by message# and optionally, lowword and long, to the window identified by handle to the Windows function SendMessage. The message is sent directly to the object, bypassing the object's message queue. Send waits until the message is processed and obtains the value returned by SendMessage.

Messages in Windows

Use the Handle function to get the Windows handle of a PowerBuilder object.

You specify Windows messages by number. They are documented in the file WINDOWS.H that is part of the Microsoft Windows Software Development Kit (SDK) and other Windows development tools.

Posting a message

Messages sent with Send are executed immediately. To post a message to the end of an object's message queue, use the Post function.

Examples

This statement scrolls the window w_emp up one page:

Send(Handle(w_emp), 277, 2, 0)

Both of the following statements click the CommandButton cb_OK:

Send(Handle(Parent), 273, 0, Handle(cb_OK))
 
cb_OK.TriggerEvent(Clicked!)

You can send messages to maximize or minimize a DataWindow, and return it to normal. To use these messages, enable the TitleBar, Minimize, and Maximize properties of your DataWindow control. Also, you should give your DataWindow control an icon for its minimized state.

This statement minimizes the DataWindow:

Send(Handle(dw_whatever), 274, 61472, 0)

This statement maximizes the DataWindow:

Send(Handle(dw_whatever), 274, 61488, 0)

This statement returns the DataWindow to its normal, defined size:

Send(Handle(dw_whatever), 274, 61728, 0)

You can send a Windows message to determine the last item clicked in a multiselect ListBox. The following script for the SelectionChanged event of a ListBox control gets the return value of the LB_GETCURSEL message which is the item number in the list (where the first item is 0, not 1).

To get PowerBuilder's index for the list item, the example adds 1 to the return value from Send. In this example, idx is an integer instance variable for the window:

// Send the Windows message for LB_GETCURSEL
// to the list box
idx = Send(Handle(This), 1033, 0, 0)
idx = idx + 1

See also

Handle

Post

Syntax2: For SMTPClient object

Description

Sends an email message to an SMTP server for delivery. This function blocks the calling thread while it transmits the message.

Applies to

SMTPClient object

Syntax

smtpclient.Send()

Argument

Description

smtpclient

A SMTP client object identifying the client in which you want to send an email message to an SMTP server.


Return value

Integer.

Returns values as follows. If any argument’s value is null, the method returns null.

  • 1 -- Success.

  • -1 -- A general error occurred.

  • -2 -- Unable to connect to service through proxy.

  • -3 -- The given proxy host could not be resolved.

  • -4 -- The given remote host could not be resolved.

  • -5 -- Failed to connect to host.

  • -6 -- Host is of bad/illegal format or is missing.

  • -7 -- Protocol is not supported.

  • -8 -- Error in SSL connection.

  • -9 -- Server certificate is revoked.

  • -10 -- Service certificate authentication failed.

  • -11 -- Operation timeout.

  • -12 -- The remote server denied the Curl login.

  • -13 -- Failed to send the network data.

  • -14 – Failure in receiving network data.

  • -15 -- Incorrect username or password.

  • -16 -- Error reading local file.

  • -17 -- No sender has been specified.

  • -18 -- No recipients have been specified.

  • -19 -- Failed to convert the parameter with its current encoding. The parameter is invalid.

  • -20 -- Failed to convert the email with its current encoding due to insufficient memory.

  • -21 -- Failed to send the email because its encoding is unsupported.

  • -22 -- Failed to convert the email with its current encoding. A general error occurred.

Examples

The following example sets the email account information and the email message, and then sends the email message.

Integer li_rc
SMTPClient  lnv_SmtpClient

lnv_SmtpClient = CREATE SMTPClient

//set the email account information     
lnv_SmtpClient.Host = "smtp.gmail.com"
lnv_SmtpClient.Port = 587
lnv_SmtpClient.Username = "tester001.appeon@gmail.com"
lnv_SmtpClient.password = "Mypassword001"
lnv_SmtpClient.EnableTLS = True

//set the email message
lnv_SmtpClient.Message.SetSender("tester001.appeon@gmail.com","Tester001")
lnv_SmtpClient.Message.AddRecipient("tester002.appeon@gmail.com")
lnv_SmtpClient.Message.Subject = "SMTPClient Test Message"
lnv_SmtpClient.Message.TextBody = "SMTPClient example message body"

//send the email message
li_rc = lnv_SmtpClient.Send()

IF li_rc = 1 THEN
 Messagebox('SMTPClient','Mail sent successfully')
ELSE
 Messagebox('SMTPClient' ,'Email sending failed. Return ' + String(li_rc) + '.', StopSign!)
END IF

DESTROY lnv_SmtpClient

See also

LogFile

SendAsync

SendAsyncCancel

SetProxy