#7994
ctaleck
Participant

    For the record, here is the code I was working with. The result is a still “X00” during the iterations.

     Sub Main(Client, GWEvent)
    
    dim iWIPFolderPath
      dim oMsg
      dim iMsgID
      dim iWIPPath
      Dim iBreakCount
    
     ' Save the draft message to the Work in Progress folder
      Call Groupwise.ItemSetText("X00", itfSubject, " COMPLETED", TRUE) ' TRUE = Append
      Utilities.Trace "iWIPPath=" & iWIPPath
      'Groupwise.ItemSaveMessageDraft(iWIPPath)
      Call Groupwise.throwtoken("ItemSaveMessageDraft(""" & iWIPPath & """)", iReturnVal)
      MsgBox "ItemSaveMessageDraft returns " & iReturnVal
    
      ' Calling ItemMessageIDFromView immediately after GroupWise.ItemSaveMessageDraft
      ' can result in an X00 ID.
      iMsgID = GroupWise.ItemMessageIDFromView
    
      iBreakCount = 0
      while (iMsgID = "Token failed execution!") or (iMsgID = "X00")
         Application.ProcessMessages
         utilities.Timer(1)
         Application.ProcessMessages
         iMsgID = GroupWise.ItemMessageIDFromView
         iBreakCount = iBreakCount + 1
         Utilities.Trace iBreakCount & ": " & iMsgID
         if (iBreakCount > 10) then
           exit sub
         end if
      wend
    
      set oMsg = GroupWise.Account.GetMessage(iMsgID)
      msgbox oMsg.subject.plaintext
    
    End Sub
    
    
    
    '-------------------------------------------------------------------------------
    ' Get full path of the Work-In-Progress folder where Drafts are saved
    '-------------------------------------------------------------------------------
    Function GetWIPFolderPath(aGWFolder, byref aPath)
      Dim sHome
      sHome = ""
      Utilities.Trace "aGWFolder.Name=" & aGWFolder.Name & " aPath=" & aPath
      If (Cint(Left(GroupWise.EnvVersionName,1)) >= 7) Then
        If aGWFolder.Name = GroupWise.Account.Owner.DisplayName Then
          sHome = " Home"
        End If
      End If
      If aGWFolder Is Nothing Then
        Exit Function
      End If
      If (aPath <> "") Then
        aPath = aGWFolder.name & sHome & "" & aPath
      Else
        aPath = aGWFolder.name
      End If
      If (aGWFolder.objtype = fgwRoot) Then
        Exit Function
      Else
        Call GetWIPFolderPath(aGWFolder.ParentFolder, aPath)
      End if
    End Function