Tcl
Tcl
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 Tcl Downloads
load ./chilkat.dll
set success 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.
set innerEmail [new_CkEmail]
CkEmail_put_Subject $innerEmail "Embedded message"
CkEmail_put_From $innerEmail "alice@example.com"
set email [new_CkEmail]
CkEmail_put_Subject $email "Has an attached message"
set success [CkEmail_AttachEmail $email $innerEmail]
if {$success == 0} then {
puts [CkEmail_lastErrorText $email]
delete_CkEmail $innerEmail
delete_CkEmail $email
exit
}
puts "NumAttachedMessages before = [CkEmail_get_NumAttachedMessages $email]"
# Remove the first attached message (index 0).
CkEmail_RemoveAttachedMessage $email 0
puts "NumAttachedMessages after = [CkEmail_get_NumAttachedMessages $email]"
delete_CkEmail $innerEmail
delete_CkEmail $email