Visual FoxPro
Visual FoxPro
Access a Part in a Multipart MIME Entity
See more MIME Examples
Demonstrates the Chilkat Mime.PartAt method, which provides live access to the direct child at a zero-based index. The first argument is the index and the second is a Mime object that will reference the child. Modifying it modifies the child stored in the parent tree.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: This is how you reach into a multipart message to inspect or edit an individual part — read a part's
Content-Type, extract an attachment's body, or change a part in place. The key point is that the returned Mime is a live reference, not a copy, so edits to it flow back into the parent tree. Loop from 0 to NumParts - 1 to visit every direct child.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loMime
LOCAL n
LOCAL loPart
LOCAL i
lnSuccess = 0
loMime = CreateObject('Chilkat.Mime')
lnSuccess = loMime.LoadMimeFile("qa_data/multipart_message.eml")
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
CANCEL
ENDIF
* PartAt provides LIVE access to a direct child part. The 1st argument is the zero-based index
* and the 2nd is a Mime object that will reference the child. Modifying it modifies the child in
* the parent tree.
n = loMime.NumParts
? "Number of parts: " + STR(n)
loPart = CreateObject('Chilkat.Mime')
FOR i = 0 TO n - 1
lnSuccess = loMime.PartAt(i,loPart)
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
RELEASE loPart
CANCEL
ENDIF
? "Part " + STR(i) + " Content-Type: " + loPart.ContentType
NEXT
RELEASE loMime
RELEASE loPart