| Home | Previous Lesson: Course 3:: Session 24 :: Page 160 Next Lesson: Course 3:: Session 24 :: Page 180 |
| Error Service
- e-Mail Notifications If you would like to automatically send an e-mail when an error occurs, you can do so with a few function calls. PFC error service provides the required functionality. First, you need to specify the severity level above which you want to send an e-mail notification. Write the following in the pfc_SystemError event. inv_Error.ofSetNotifySeverity( 10 ) The above function says, send e-mail notification only for errors with severity level 10 or above. Now, you should connect to the e-mail system. Before that, declare the following instance variables: n_ms
ims_MailSession Write the following code to the pfc_SystemError event at the n_cst_AppManager object. MailReturnCode lmrc_RetCode
ims_MailSession = CREATE n_ms
lmrc_RetCode = ims_MailSession.MailLogOn()
If lmrc_RetCode <> MailReturnSuccess! Then
MessageBox( "Mail Login Error", &
"Unable to Login to " + "the Mail System.")
Return
End If
li_rc = inv_Error.of_SetNotifyConnection( ims_MailSession )
If li_rc = -1 Then
MessageBox( "Mail Error",
"Unable to use the mail session.")
Return
End if
ls_EMailList[1] = "prasad bodepudi" li_rc = inv_Error.of_SetNotifyWho( ls_EMailList[] ) We are creating a mail session and logging into the mail system using the MailLogOn(). Depending on your mail system settings, either you will be prompted for your login details or logs into the mail system automatically. Then we are asking the PFC to use the mail session we have just created for error e-mail notification. We are populating all the user names that we want to get informed when error occurs in an array and asking the PFC to use that users list. Now, when you call of_Message() at the inv_Error object, PowerBuilder sends e-mails to each user listed in the user list. Make sure to destroy the object in the n_cst_AppManagers destructor event. If IsValid( ims_MailSession ) Then DESTROY ims_MailSession |
| Home | Previous Lesson: Course 3:: Session 24 :: Page 160 Next Lesson: Course 3:: Session 24 :: Page 180 |