code: public MessageInfo getMessageOut(MessageProcessInfo recMessageProcessInfo)
      {
          MessageProcessInfo recMessageProcessInfo2 =  (MessageProcessInfo)((ReferenceField)recMessageProcessInfo.getField(MessageProcessInfo.REPLY_MESSAGE_PROCESS_INFO_ID)).getReference();
          if (recMessageProcessInfo2 != null)
              return (MessageInfo)((ReferenceField)recMessageProcessInfo2.getField(MessageProcessInfo.MESSAGE_INFO_ID)).getReference();
          return null;
      }
docs: GetMessageOut Method.