Microsoft KB Archive/175432: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 64: Line 64:
   *bypassed by providing a valid ProfileName as the first parameter
   *bypassed by providing a valid ProfileName as the first parameter
   *(as a string) to the Logon Method as seen below.
   *(as a string) to the Logon Method as seen below.
   objSession = CREATEOBJECT("mapi.session")
   objSession = CREATEOBJECT("mapi.session")
   objSession.Logon("Stevekl")
   objSession.Logon("Stevekl")


   *Get a sample message - for this example we'll take whatever is at
   *Get a sample message - for this example we'll take whatever is at
Line 81: Line 81:
       *Display Name, Value, Type, and ID properties of the Field Object
       *Display Name, Value, Type, and ID properties of the Field Object
       DO CASE
       DO CASE
         CASE TYPE("objFieldsColl.Item(ctrThisField).Value") = "C"
         CASE TYPE("objFieldsColl.Item(ctrThisField).Value") = "C"
             strValue = objFieldsColl.Item(ctrThisField).Value
             strValue = objFieldsColl.Item(ctrThisField).Value
         CASE TYPE("objFieldsColl.Item(ctrThisField).Value") = "N"
         CASE TYPE("objFieldsColl.Item(ctrThisField).Value") = "N"
             strValue = ;
             strValue = ;
               ALLTRIM(STR(objFieldsColl.Item(ctrThisField).Value,30,10))
               ALLTRIM(STR(objFieldsColl.Item(ctrThisField).Value,30,10))
Line 89: Line 89:
             *There is a potential that a field may contain data types
             *There is a potential that a field may contain data types
             *not support for display by Visual FoxPro.
             *not support for display by Visual FoxPro.
             strValue = "Not Displayed"
             strValue = "Not Displayed"
       ENDCASE
       ENDCASE
       MESSAGEBOX(;
       MESSAGEBOX(;
         "Field #" + ALLTRIM(STR(ctrThisField)) + " of " ;
         "Field #" + ALLTRIM(STR(ctrThisField)) + " of " ;
         +    ALLTRIM(STR(intFldCnt)) ;
         +    ALLTRIM(STR(intFldCnt)) ;
         +    CHR(13) + CHR(10) ;
         +    CHR(13) + CHR(10) ;
         + "Name : " ;
         + "Name : " ;
         +    objFieldsColl.Item(ctrThisField).Name ;
         +    objFieldsColl.Item(ctrThisField).Name ;
         +    CHR(13) + CHR(10) ;
         +    CHR(13) + CHR(10) ;
         + "Value: " ;
         + "Value: " ;
         +    strValue ;
         +    strValue ;
         +    CHR(13) + CHR(10) ;
         +    CHR(13) + CHR(10) ;
         + "Type : " ;
         + "Type : " ;
         +    ALLTRIM(STR(objFieldsColl.Item(ctrThisField).Type)) ;
         +    ALLTRIM(STR(objFieldsColl.Item(ctrThisField).Type)) ;
         +    CHR(13)+CHR(10) ;
         +    CHR(13)+CHR(10) ;
         + "ID  : " ;
         + "ID  : " ;
         +    ALLTRIM(STR(objFieldsColl.Item(ctrThisField).ID,20)))
         +    ALLTRIM(STR(objFieldsColl.Item(ctrThisField).ID,20)))



Latest revision as of 11:07, 21 July 2020

Knowledge Base


How To Walk the Fields Collection of a Message in Active Msg

Article ID: 175432

Article Last Modified on 3/11/2005



APPLIES TO

  • Microsoft Visual FoxPro 3.0 Standard Edition
  • Microsoft Visual FoxPro 3.0b Standard Edition
  • Microsoft Visual FoxPro 5.0 Standard Edition
  • Microsoft Visual FoxPro 5.0a
  • Microsoft Visual FoxPro 6.0 Professional Edition



This article was previously published under Q175432

SUMMARY

Many Visual FoxPro developers might not be aware that the Active Messaging library exists for them to use as an extremely robust alternative to canned mail messaging API (MAPI) controls. This article is designed as part of a short (non-interdependent) series intended to provide Visual FoxPro developers with information, development tips, and useful snippets about the Microsoft Active Messaging Library.

This article introduces some aspects of working with a Message objects Fields Collection by providing a short code snippet demonstrating how to cycle through the Fields Collection of a sample Message.

MORE INFORMATION

Cycling through the fields collection can be particularly useful when trying to debug a Messaging application. This is especially true if this method is built upon to allow walking the collections of two different messages simultaneously and finding the differences between them.

   * AM_FieldData.PRG
   * ----------------
   *
   *Create a MAPI Session object then Logon. The Logon dialog can be
   *bypassed by providing a valid ProfileName as the first parameter
   *(as a string) to the Logon Method as seen below.
   objSession = CREATEOBJECT("mapi.session")
   objSession.Logon("Stevekl")

   *Get a sample message - for this example we'll take whatever is at
   *the top of the Inbox
   objMessage = objSession.Inbox.Messages.GetFirst
   objFieldsColl = objMessage.Fields

   *A key component of a Message Object is it's Fields Collection. The
   *Fields Collection is composed of a variable number of Field Objects
   *that each possess the properties: Name, Value, Type, and ID
   intFldCnt = objFieldsColl.Count
   ctrThisField = 1
   FOR ctrThisField =1 TO intFldCnt

      *Display Name, Value, Type, and ID properties of the Field Object
      DO CASE
         CASE TYPE("objFieldsColl.Item(ctrThisField).Value") = "C"
            strValue = objFieldsColl.Item(ctrThisField).Value
         CASE TYPE("objFieldsColl.Item(ctrThisField).Value") = "N"
            strValue = ;
               ALLTRIM(STR(objFieldsColl.Item(ctrThisField).Value,30,10))
         OTHERWISE
            *There is a potential that a field may contain data types
            *not support for display by Visual FoxPro.
            strValue = "Not Displayed"
      ENDCASE
      MESSAGEBOX(;
         "Field #" + ALLTRIM(STR(ctrThisField)) + " of " ;
         +    ALLTRIM(STR(intFldCnt)) ;
         +    CHR(13) + CHR(10) ;
         + "Name : " ;
         +    objFieldsColl.Item(ctrThisField).Name ;
         +    CHR(13) + CHR(10) ;
         + "Value: " ;
         +    strValue ;
         +    CHR(13) + CHR(10) ;
         + "Type : " ;
         +    ALLTRIM(STR(objFieldsColl.Item(ctrThisField).Type)) ;
         +    CHR(13)+CHR(10) ;
         + "ID   : " ;
         +    ALLTRIM(STR(objFieldsColl.Item(ctrThisField).ID,20)))

   NEXT ctrThisField

   *Clean up then exit
   objSession.Logoff
   RELEASE objFieldsColl, objMessage, objSession
                

REFERENCES

For additional information on where to acquire the Active Messaging library, see the following information in the Microsoft Knowledge Base:

171440 Where to Acquire the Collaboration Data Objects Library




Further generic information on Active Messaging can be found on the Microsoft Developer Network,or in the Olemsg.hlp file, which can be obtained by following the directions in Q171440.


Additional query words: VFoxWin

Keywords: kbhowto kbcode KB175432