DataFlex
DataFlex
Get an Email's MIME into a StringBuilder
See more Email Object Examples
Demonstrates the Chilkat Email.GetMimeSb method, which returns the email as MIME text (header, body or bodies, related items, and all attachments) by appending it to a StringBuilder object. This example builds a message and appends its MIME to a StringBuilder.
Background: This is a
StringBuilder-based alternative to GetMime, which returns a plain string. Writing into a StringBuilder is more efficient when the MIME is large or when you intend to further manipulate it — searching, replacing, or accumulating additional text — without creating many intermediate string copies.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoEmail
Variant vSbMime
Handle hoSbMime
String sTemp1
Move False To iSuccess
// Demonstrates the GetMimeSb method, which returns the email as MIME text (headers, bodies,
// related items, and attachments), appending it to a StringBuilder object.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "GetMimeSb example"
Set ComFrom Of hoEmail To "alice@example.com"
Get ComAddTo Of hoEmail "Bob" "bob@example.com" To iSuccess
Set ComBody Of hoEmail To "Hello!"
// Append the complete MIME to a StringBuilder.
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbMime
If (Not(IsComObjectCreated(hoSbMime))) Begin
Send CreateComObject of hoSbMime
End
Get pvComObject of hoSbMime to vSbMime
Get ComGetMimeSb Of hoEmail vSbMime To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComGetAsString Of hoSbMime To sTemp1
Showln sTemp1
End_Procedure