Mastering PowerBuilder

HomePrevious Lesson: Course 3:: Session 26 :: Page 100
Next Lesson: Course 3:: Session 26 :: Page 120
Creating a New Mail

Composing a new mail involves setup of lot of properties in the MailMessage object. Let us learn one step at a time.

mMsg.Subject = mle_subject.text

The above code is setting the subject of the mail.

If cbx_receipt_requested.checked Then
	mMsg.ReceiptRequested = true
End If

The above code fragment is checking whether the user is requesting the 'receipt request' and setting 'ReceiptRequested' property.

mMsg.notetext = mle_msg.text +"~n~r "

The above code is setting the text of the mail message along with a carriage return and a line feed.

mAttach.FileType = mailAttach!
mAttach.PathName = ls_attach_name
mAttach.FileName = ls_attach_name

// Note: In MS Mail version 3.0b, Position=-1 puts
// attachment at the beginning of the message. This
// will place the attachment at the End of the text of
// the message

mAttach.Position = len(mMsg.notetext) - 1
mMsg.AttachmentFile[1] = mAttach

Here we are specifying the attachment details such as attachment file name and full path name and the position where the attachment should be placed in the text of the mail. The above code fragment is placing the attachments at the end of the text.

You can allow the user to specify the recipient names in different ways. User can type or select from a DataWindow or read all the addresses from a text file or make use of mail system address book. Once you know the recipient name, you can set the recipient name as shown below:

mMsg.Recipient[li_nrecipients].Name = ls_name

The 'Name' property in the Recipient[] structure array in the MailMessage object is being set.

If you want the user to select recipient addresses from the mail system address book you can call MailAddress(). Calling this function with an argument will display the mail system address list.

When you get recipient addresses from any other source other than MailAddress() it is a good idea to check the correctness of those addresses by calling MailResolveRecipient().

HomePrevious Lesson: Course 3:: Session 26 :: Page 100
Next Lesson: Course 3:: Session 26 :: Page 120