Sample code for 30+ languages & platforms
Xbase++

Create Email with Non-Standard Binary Body

Creates an email where the only body is a binary WAV file. The technique used in the example could be applied to other binary files, such as PDF, MS-WORD docs, Excel docs, etc.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oMime
LOCAL cStrMime
LOCAL oEmail

nSuccess := 0

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oMime := CreateObject("Chilkat.Mime")

nSuccess := oMime:SetBodyFromFile("VoiceMessage.wav")
IF (nSuccess == 0)
    ? oMime:LastErrorText
    oMime:destroy()
    RETURN
ENDIF

//  The MIME has this header:
//  Content-Disposition: attachment;
//  	 filename="VoiceMessage.wav"
//  Content-Transfer-Encoding: base64
//  Content-Type: audio/x-wav;
//  	name="VoiceMessage.wav"

//  We don't want the content-disposition to be an
//  attachment -- otherwise the email object will self-correct
//  and put it in a multipart/mixed format...
oMime:Disposition := ""
oMime:Filename := ""

cStrMime := oMime:GetMime()
? cStrMime

//  Now load it into an email object:
oEmail := CreateObject("Chilkat.Email")
nSuccess := oEmail:SetFromMimeText(cStrMime)
IF (nSuccess == 0)
    ? oEmail:LastErrorText
    oMime:destroy()
    oEmail:destroy()
    RETURN
ENDIF

//  Add subject, TO, FROM, etc.
oEmail:Subject := "This is a test"
oEmail:From := "support@chilkatsoft.com"
nSuccess := oEmail:AddTo("Matt", "matt@chilkatsoft.com")

//  Your email is ready to send.
//  (but for this example, we'll simply save it to a file...)
nSuccess := oEmail:SaveEml("email.eml")
IF (nSuccess == 0)
    ? oEmail:LastErrorText
    oMime:destroy()
    oEmail:destroy()
    RETURN
ENDIF

? "OK!"

oMime:destroy()
oEmail:destroy()