DataFlex
DataFlex
Render an Email to MIME in a StringBuilder
See more SMTP Examples
Demonstrates the Chilkat MailMan.RenderToMimeSb method, which renders an Email object as MIME text and appends the result to a StringBuilder, without sending the email. This example renders a message into a StringBuilder and prints it.
Background: This is the
StringBuilder version of RenderToMime. Appending into a StringBuilder is more efficient when the MIME is large or when you plan to further inspect or manipulate it — searching, replacing, or accumulating additional text — without creating extra intermediate string copies.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMailman
Variant vEmail
Handle hoEmail
Variant vSbMime
Handle hoSbMime
String sTemp1
Move False To iSuccess
// Demonstrates the MailMan.RenderToMimeSb method, which renders an Email object as MIME text
// and appends the result to a StringBuilder (without sending the email).
Get Create (RefClass(cComChilkatMailMan)) To hoMailman
If (Not(IsComObjectCreated(hoMailman))) Begin
Send CreateComObject of hoMailman
End
// Build the email to render.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "Rendered email"
Set ComFrom Of hoEmail To "alice@example.com"
Get ComAddTo Of hoEmail "Bob" "bob@example.com" To iSuccess
Set ComBody Of hoEmail To "This message is rendered to MIME in a StringBuilder."
// Render the MIME into a StringBuilder.
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbMime
If (Not(IsComObjectCreated(hoSbMime))) Begin
Send CreateComObject of hoSbMime
End
Get pvComObject of hoEmail to vEmail
Get pvComObject of hoSbMime to vSbMime
Get ComRenderToMimeSb Of hoMailman vEmail vSbMime To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComGetAsString Of hoSbMime To sTemp1
Showln sTemp1
End_Procedure