Visual FoxPro
Visual FoxPro
Remove a Single Attached Message from an Email
See more Email Object Examples
Demonstrates the Chilkat Email.RemoveAttachedMessage method, which removes the Nth message/rfc822 sub-part (an attached email) from the message. Indexing begins at 0. This example attaches an email, removes it, and prints the attached-message count before and after.
Background: Attached messages (forwarded emails carried as
message/rfc822 parts) are counted and indexed separately from ordinary file attachments and related items. RemoveAttachedMessage targets just one nested email by index — useful, for example, when trimming a bundled digest or stripping a forwarded original before re-sending.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loInnerEmail
LOCAL loEmail
lnSuccess = 0
* Demonstrates the RemoveAttachedMessage method, which removes the Nth message/rfc822
* sub-part (attached email) of the email. The index is zero-based.
* Build an inner email and attach it to an outer email.
loInnerEmail = CreateObject('Chilkat.Email')
loInnerEmail.Subject = "Embedded message"
loInnerEmail.From = "alice@example.com"
loEmail = CreateObject('Chilkat.Email')
loEmail.Subject = "Has an attached message"
lnSuccess = loEmail.AttachEmail(loInnerEmail)
IF (lnSuccess = 0) THEN
? loEmail.LastErrorText
RELEASE loInnerEmail
RELEASE loEmail
CANCEL
ENDIF
? "NumAttachedMessages before = " + STR(loEmail.NumAttachedMessages)
* Remove the first attached message (index 0).
loEmail.RemoveAttachedMessage(0)
? "NumAttachedMessages after = " + STR(loEmail.NumAttachedMessages)
RELEASE loInnerEmail
RELEASE loEmail