LotusScript to C API Programming Guide

rtLib Domino Rich Text Management template
Home
Show details for ContentContent
Purchase
Ready-to-use samples
Show details for Online resourcesOnline resources
Forum
Links
Happy readers

Anonymous

login


 

Hosted by Prominic.NET, Inc.
Main topic: 64Kb barrier problem using ListAllocate, ListAddEntry and MailExpandNames functions

64Kb barrier problem using ListAllocate, ListAddEntry and MailExpandNames functions (by Andrew Luder, 06/27/2004 06:24:07 AM)

Normunds,

on page 305 of your book you mentioned not finding a need for the ListAllocate or ListAddEntry API functions. I've found a use for them in trying to validate a Mail Recipient List.

Rather that using $ExpandGroups = 3, I've successfully redirected the Memo fields EnterSendTo, EnterCopyTo and EnterBlindCopyTo into a List in memory. The list is then passed to the MailExpandNames function. It works OK when the list has groups with users that expand to less than 64Kb. Over the 64Kb the MailExpandNames function produces the error message "Adding entry will cause text list to exceed 64Kb".

Is there anyway around this or is it a limitation of the MailExpandNames function and the way Notes allocates memory to handles (I'm using R5011 on W32 client and server)?

My code is below:

Options

*******

Const APIModule = "NNOTES"

Const OS_TRANSLATE_LMBCS_TO_NATIVE = 1

Const MAX_SERVER_NAME = 256

Declarations

************

Declare Function OSLoadString Lib APIModule Alias "OSLoadString" _

(Byval hModule As Long, Byval StringCode As Integer, Byval retBuffer As Lmbcs String _

, Byval BufferLength As Integer) As Integer

Declare Function OSMemFree Lib APIModule Alias "OSMemFree" _

( Byval Handle As Long) As Integer

Declare Function OSLockObject Lib APIModule Alias "OSLockObject" _

( Byval H As Long) As Long

Declare Sub OSUnlockObject Lib APIModule Alias "OSUnlockObject" _

( Byval H As Long)

Declare Function ListAllocate Lib APIModule Alias "ListAllocate" _

( Byval ListEntries As Integer, Byval TextSize As Long, Byval Prefix_Flag As Integer _

, hList As Long, pList As Long, ListSize As Long) As Integer

Declare Function ListGetNumEntries Lib APIModule Alias "ListGetNumEntries" _

( Byval pList As Long, Byval Prefix_Flag As Integer) As Integer

Declare Function ListAddEntry Lib APIModule Alias "ListAddEntry" _

( Byval hList As Long,Byval Prefix_Flag As Integer, ListSize As Long ,Byval EntryNumber As Long _

, Byval TextListItem As Lmbcs String, Byval TextListItemSize As Long) As Integer

Declare Function MailExpandNames Lib APIModule Alias "MailExpandNames" _

( Byval hList As Long, Byval WorkListSize As Long, OutputList As Long _

, OutputListSize As Long, Byval UseExpanded As Integer, Byval RecipsExpanded As Long) As Integer

Declare Function ListGetText Lib APIModule Alias "ListGetText" _

( Byval pList As Long, Byval Prefix_Flag As Integer, Byval EntryNumber As Long _

, RetTextPointer As Long, RetTextLength As Long) As Integer

Declare Function OSTranslate Lib APIModule Alias "OSTranslate" _

( Byval nTranslateMode As Integer, Byval dwIn As Long, Byval nLength As Long, _

Byval lpszOut As String, Byval nOutLength As Long) As Integer

Subroutine and function

***********************

Sub PrintExpandedRecipientArray(RecipientArray as variant)

   Dim hList As Long,RecipientList As Long,pList As Long, RecipientHold As Long

   Dim OutputListSize As Long, ListSize As Long, entryvaluesize As Long

   Dim noentries As Long, nStatus As Long, nCount As Long, nLength As Long

   Dim entryvalue As String, lpRecipient As String

   Dim x As Long, MENstatus As Integer

      

   If ListAllocate(0, 0, True, hList, pList,ListSize) = 0 Then

      For x = 0 To Ubound(RecipientArray)

         noentries = ListGetNumEntries(plist,True)

         OSUnlockObject(hList)

         entryvalue = RecipientArray(x)

         entryvaluesize = Len(RecipientArray(x))   

         

         If ListAddEntry(hList, True,ListSize,noentries,entryvalue,entryvaluesize) = 0 Then

            plist = OSLockObject(hList)

         Else

            Print "Error adding List Entry"

            Exit Function

         End If

      Next

         

      

      MENstatus = MailExpandNames(hList,ListSize,RecipientList,OutputListSize,False,0)

      

      If MENstatus = 0 Then

         plist = OSLockObject(RecipientList)

         nCount= 0

         Do While nStatus =0

            nStatus = ListGetText(plist, True, nCount, RecipientHold, nLength)

            If nStatus = 0 And nLength > 0 Then

               lpRecipient =Space$(nLength)

               Call OSTranslate(OS_TRANSLATE_LMBCS_TO_NATIVE, RecipientHold, nLength, lpRecipient, MAX_SERVER_NAME)

               Print lpRecipient                   

            End If      

            nCount=nCount+1      

         Loop

         

         Call OSUnlockObject(RecipientList)

         Call OSMemFree(RecipientList)

      Else

         Print "Error Expandiing Recipient List - " + GetError(MENstatus)         

      End If

      

   Else

      Print "Error allocating memory for List"

   End If

End Sub

Function getError (enum As Integer) As String

   Dim iLen As Integer

   Dim lenBuffer As Integer

   Dim sBuffer As String

   

      ' --- initialize a buffer of adequate length to accept the error string

   lenBuffer = 256

   sBuffer = String$(lenBuffer, 0)

   

      ' --- get the API error message from the internal Notes/Domino string tables

   iLen = OSLoadString(0, enum , sBuffer, lenBuffer - 1)

   

   If iLen > 0 Then

      ' --- remove any trailing characters from the string and return it to the caller

      getError = Left$(sBuffer, Instr(1, sBuffer, Chr$(0)) - 1)

   Else

      ' --- couldn't locate the error message in the string tables

      getError= "Unknown error"

   End If   

End Function