Sends a mail message. If no message information is supplied, the mail system provides a dialog box for entering it before sending the message.
mailSession object
mailsession.mailSend ( { mailmessage } )
Argument |
Description |
---|---|
mailsession |
A mailSession object identifying the session in which you want to send the mail message |
mailmessage (optional) |
A mailMessage structure |
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.
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!.
These statements create a mail session, send a message, and then log off the mail system and destroy the mail session object:
mailSession mSes
mailReturnCode mRet
mailMessage mMsg
// Create a mail session
mSes = create mailSession
// Log on to the session
mRet = mSes.mailLogon(mailNewSession!)
IF mRet <> mailReturnSuccess! THEN
MessageBox("Mail", 'Logon failed.')
RETURN
END IF
// Populate the mailMessage structure
mMsg.Subject = mle_subject.Text
mMsg.NoteText = 'Luncheon at 12:15'
mMsg.Recipient[1].name = 'Smith, John'
mMsg.Recipient[2].name = 'Shaw, Sue'
// Send the mail
mRet = mSes.mailSend(mMsg)
IF mRet <> mailReturnSuccess! THEN
MessageBox("Mail Send", 'Mail not sent')
RETURN
END IF
mSes.mailLogoff()
DESTROY mSes
See also the mail examples in the samples supplied with PowerBuilder.