| Home | Previous Lesson: Course 3:: Session 26 :: Page 80 Next Lesson: Course 3:: Session 26 :: Page 100 |
| Reading
Unread Mail Messages To read the full content of a message you need to call MailReadMessage() you used in the previous topic. However, you need to send MailEntireMessage! Argument instead of MailEnvelopeOnly! to the MailReadMessage(). Once you read the message content it is up to you to decide what you want to do with the read message. In the following example, the message is being displayed on the window. This code is also looking for any PSR file attachments and assigning those PSR attachments to a DataWindow control for display. // Clicked script for dw_inbox mailReturnCode mRet mailMessage mMsg[] mailFileDescription mAttach int li_attachment, li_file, li_ret int li_recips, li_index string ls_messageid string ls_ret, ls_syntax, ls_name, ls_open_pathname string ls_filename // Obtain mail Message ID and which attachment is the // DataWindow to receive and display ls_messageid = this.object.MessageID[row] li_attachment = this.object.Attachment_number[row] // Re-read this message to obtain entire contents, // including the attached file (because the Open script // read only the "envelope" and not the contents of the // message) mRet = ims_mses.mailReadMessage ( ls_messageid, mMsg[1], &
mailEntireMessage!, TRUE )
ls_ret = f_mail_error_to_string ( mRet, 'Read Message:', &
FALSE )
st_status_bar.text = ' Read Message: ' + ls_ret
mle_to.text = ""
li_recips = Upperbound(mMsg[1].Recipient)
FOR li_index = 1 to li_recips
//get the from name
If mMsg[1].Recipient[li_index].RecipientType &
= mailOriginator! Then
sle_from.text = mMsg[1].Recipient[li_index].name
End If
//get the to and cc names .. put ; between each one
If mMsg[1].Recipient[li_index].RecipientType = &
mailTo! or mMsg[1].Recipient[li_index].&
RecipientType = mailCC! Then
If mle_to.text = "" Then
mle_to.text = MMsg[1].Recipient[li_index].name
Else
mle_to.text = mle_to.text + "; " + &
MMsg[1].Recipient[li_index].name
End If
End If
Next
//set subject sle_subject.text = mMsg[1].subject //set message text mle_message.text = mMsg[1].NoteText // Extract the name of the temporary file in which the mail // system has stored the attachment file, and open that // file test if there was a DataWindow If li_attachment = 0 Then dw_1.visible = false cb_print.enabled = false return End If ls_open_pathname = mMsg[1].AttachmentFile[li_attachment].&
PathName
//assign the psr file to the DataWindow object
dw_1.dataobject = ls_open_pathname
When you read the mail message it is populated into a structure of type MailMessage. You may have seen it in 'Mail Objects (Structures)' section; MailMessage is a structure object. MailFileDescription and MailRecipient are also structure objects and these two structures are properties of MailMessage object. By checking the RecipientType property in the MailRecipient object you can find out whether the recipient is 'To', 'CC', 'Bcc'. |
| Home | Previous Lesson: Course 3:: Session 26 :: Page 80 Next Lesson: Course 3:: Session 26 :: Page 100 |