DataFlex
DataFlex
Embed a Message as message/rfc822
See more MIME Examples
Demonstrates the Chilkat Mime.NewMessageRfc822 method, which clears the object and initializes it as a message/rfc822 entity whose body is a serialized copy of another Mime. The only argument is the message to embed.
Background:
message/rfc822 wraps a whole email as the body of another — the mechanism behind forwarding a message "as attachment" or bundling one message inside another. The inner message is copied at the time of the call, so later edits to the source do not change the embedded copy. The result is a self-contained part a mail client will present as a nested message.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Variant vInnerMsg
Handle hoInnerMsg
Handle hoMime
String sTemp1
Move False To iSuccess
// Demonstrates the Mime.NewMessageRfc822 method, which clears the current object and initializes
// it as a message/rfc822 entity whose body is a serialized copy of another Mime. The only
// argument is the Mime to embed.
// Build the inner message to embed.
Get Create (RefClass(cComChilkatMime)) To hoInnerMsg
If (Not(IsComObjectCreated(hoInnerMsg))) Begin
Send CreateComObject of hoInnerMsg
End
Get ComSetHeaderField Of hoInnerMsg "Subject" "Forwarded message" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoInnerMsg To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComSetBodyFromPlainText Of hoInnerMsg "This is the original message being forwarded." To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoInnerMsg To sTemp1
Showln sTemp1
Procedure_Return
End
// Wrap it as message/rfc822 (an embedded/forwarded email).
Get Create (RefClass(cComChilkatMime)) To hoMime
If (Not(IsComObjectCreated(hoMime))) Begin
Send CreateComObject of hoMime
End
Get pvComObject of hoInnerMsg to vInnerMsg
Get ComNewMessageRfc822 Of hoMime vInnerMsg To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComContentType Of hoMime To sTemp1
Showln "Content-Type: " sTemp1
End_Procedure