Sample code for 30+ languages & platforms
CkJava Requires Chilkat v11.0.0+

Make an audio file the entire MIME body

See more Email Object Examples

Use a single audio/wav part when an integration expects the payload itself to be audio. A conventional email addressed to a person can instead carry a text body and a file attachment. Supply a local recording named recording.wav.

Chilkat CkJava Downloads

CkJava
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    //  Assumes Chilkat is unlocked. See Global Unlock Sample.

    CkMime mime = new CkMime();
    success = mime.SetBodyFromFile("recording.wav");
    if (success != true) {
        System.out.println(mime.lastErrorText());
        return;
        }

    mime.put_ContentType("audio/wav");
    mime.put_Disposition("");
    mime.put_Filename("");
    CkBinData mimeBytes = new CkBinData();
    success = mime.GetMimeBd(mimeBytes);
    if (success != true) {
        System.out.println(mime.lastErrorText());
        return;
        }

    CkEmail email = new CkEmail();
    success = email.SetFromMimeBd(mimeBytes);
    if (success != true) {
        System.out.println(email.lastErrorText());
        return;
        }

    email.put_From("Workshop team <events@example.com>");
    success = email.AddTo("Audio archive","audio@example.net");
    if (success != true) {
        System.out.println(email.lastErrorText());
        return;
        }

    email.put_Subject("Workshop recording");

    success = email.SaveEml("audio.eml");
    if (success != true) {
        System.out.println(email.lastErrorText());
        return;
        }

    System.out.println("Saved audio.eml.");
  }
}