Click or drag to resize

DecodeBase64 Function

Decode a file from an e-mail transfer.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.2a
Syntax
 FUNCTION DecodeBase64(
	cAttachment AS STRING,
	hDestination AS IntPtr
) AS LONG
View Source

Parameters

cAttachment
Type: String
The attachment text to decode.
hDestination
Type: IntPtr
Handle of the file to which the decoded text is to be written.

Return Value

Type: Int32
The number of bytes that were decoded.
Remarks
Base64 decoding is used to read file attachments from messages sent over the Internet.
Examples
Assuming that the mail message received was properly parsed and the attachment portion was saved to <cFilePart>, this is how you could decode the attachment:
X#
hOut := FCreate("Attachment.txt")
IF hfOut != F_ERROR
        nTotalBytes := DecodeBase64(cFilePart, hOut)
        TextBox{,"Decode", "Bytes Decoded: " + ;
                        AsString(nTotalBytes)}:Show()
ENDIF
FClose(hfOut)
For a more complete example of DecodeBase64(), including how to parse an e-mail message, see the Mime Decoding sample application (CAVOxx\SAMPLES\INTERNET\MIME\MDECODE.AEF).
See Also

Reference

CLASS CEmail
CLASS CMailAbstract
CLASS CSmtp