DataFlex
DataFlex
Get an Email's MIME into a BinData
See more Email Object Examples
Demonstrates the Chilkat Email.GetMimeBd method, which serializes the complete RFC822/MIME message (headers, body representations, related items, and attachments) and appends the bytes to a BinData object. This example builds a message, serializes it to a BinData, and prints the byte count.
Background: A
BinData holds raw bytes, which is the right container when you want the MIME as binary rather than text — for example to write it directly to a file or socket, hash it, or hand it to another API that expects a byte buffer. It is the binary counterpart to GetMime (string) and GetMimeSb (StringBuilder).Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoEmail
Variant vBdMime
Handle hoBdMime
String sTemp1
Integer iTemp1
Move False To iSuccess
// Demonstrates the GetMimeBd method, which serializes the complete RFC822/MIME message
// (headers, bodies, related items, and attachments) and appends the bytes to a BinData
// object.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "GetMimeBd 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 BinData object.
Get Create (RefClass(cComChilkatBinData)) To hoBdMime
If (Not(IsComObjectCreated(hoBdMime))) Begin
Send CreateComObject of hoBdMime
End
Get pvComObject of hoBdMime to vBdMime
Get ComGetMimeBd Of hoEmail vBdMime To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComNumBytes Of hoBdMime To iTemp1
Showln "MIME size (bytes) = " iTemp1
End_Procedure