Article ID: 175432
Article Last Modified on 3/11/2005
* 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
171440 Where to Acquire the Collaboration Data Objects Library
Additional query words: VFoxWin
Keywords: kbhowto kbcode KB175432