PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkEmail.pb"
Procedure ChilkatExample()
success.i = 0
; Demonstrates the GetMimeSb method, which returns the email as MIME text (headers, bodies,
; related items, and attachments), appending it to a StringBuilder object.
email.i = CkEmail::ckCreate()
If email.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkEmail::setCkSubject(email, "GetMimeSb example")
CkEmail::setCkFrom(email, "alice@example.com")
CkEmail::ckAddTo(email,"Bob","bob@example.com")
CkEmail::setCkBody(email, "Hello!")
; Append the complete MIME to a StringBuilder.
sbMime.i = CkStringBuilder::ckCreate()
If sbMime.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkEmail::ckGetMimeSb(email,sbMime)
If success = 0
Debug CkEmail::ckLastErrorText(email)
CkEmail::ckDispose(email)
CkStringBuilder::ckDispose(sbMime)
ProcedureReturn
EndIf
Debug CkStringBuilder::ckGetAsString(sbMime)
CkEmail::ckDispose(email)
CkStringBuilder::ckDispose(sbMime)
ProcedureReturn
EndProcedure