mailSend PowerScript function
Description
Sends a mail message. If no message information is supplied,
the mail system provides a dialog box for entering it before sending
the message.
Controls
mailSession object
Syntax
1 |
<span>mailsession</span>.<span>mailSend</span> ( { <span>mailmessage</span> } ) |
Argument |
Description |
---|---|
mailsession |
A mailSession object identifying the |
mailmessage (optional) |
A mailMessage structure |
Return Values
mailReturnCode. Returns one of the following values:
-
mailReturnSuccess!
-
mailReturnFailure!
-
mailReturnInsufficientMemory!
-
mailReturnLoginFailure!
-
mailReturnUserAbort!
-
mailReturnDiskFull!
-
mailReturnTooManySessions!
-
mailReturnTooManyFiles!
-
mailReturnTooManyRecipients!
-
mailReturnUnknownRecipient!
-
mailReturnAttachmentNotFound!
If any argument’s value is null,
mailSend returns null.
Usage
Before calling mail functions, you must declare and create
a mailSession object and call mailLogon to establish
a mail session.
For mailSend, mailOriginator! is not a valid value for the
Recipient property of the mailMessage object.
The valid values are mailto!, mailcc!, and mailbcc!. To specify
that the sender receive a copy of the message, use mailcc!.
Examples
These statements create a mail session, send a message,
and then log off the mail system and destroy the mail session object:
1 |
mailSession mSes |
1 |
mailReturnCode mRet |
1 |
mailMessage mMsg |
1 |
1 |
// Create a mail session |
1 |
mSes = create mailSession |
1 |
1 |
// Log on to the session |
1 |
mRet = mSes.mailLogon(mailNewSession!) |
1 |
IF mRet <> mailReturnSuccess! THEN |
1 |
MessageBox("Mail", 'Logon failed.') |
1 |
RETURN |
1 |
END IF |
1 |
1 |
// Populate the mailMessage structure |
1 |
mMsg.Subject = mle_subject.Text |
1 |
mMsg.NoteText = 'Luncheon at 12:15' |
1 |
mMsg.Recipient[1].name = 'Smith, John' |
1 |
mMsg.Recipient[2].name = 'Shaw, Sue' |
1 |
1 |
// Send the mail |
1 |
mRet = mSes.<span>mailSend</span>(mMsg) |
1 |
1 |
IF mRet <> mailReturnSuccess! THEN |
1 |
MessageBox("Mail Send", 'Mail not sent') |
1 |
RETURN |
1 |
END IF |
1 |
1 |
mSes.mailLogoff() |
1 |
DESTROY mSes |
See also the mail examples in the samples supplied with PowerBuilder.