Click or drag to resize

DecodeBase64 Function

X#
Decode a file from an e-mail transfer.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax
 FUNCTION DecodeBase64(
	cAttachment AS STRING,
	hDestination AS IntPtr
) AS LONG
Request Example 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: Long
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#
1hOut := FCreate("Attachment.txt")
2IF hfOut != F_ERROR
3    nTotalBytes := DecodeBase64(cFilePart, hOut)
4    TextBox{,"Decode", "Bytes Decoded: " + ;
5            AsString(nTotalBytes)}:Show()
6ENDIF
7FClose(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