1

I want to send an email with 9 specific bytes in the body:

byte one = (byte) 161;
byte two = (byte) 1;
byte three = (byte) 254;
byte four = (byte) 1;
byte five = (byte) 255;
byte six = (byte) 255;
byte seven = (byte) 255;
byte eight = (byte) 254;
byte nein = (byte) 255;

String unicode = new String(new byte[] { one, two, three, four, five, six, seven, eight, nein }, "windows-1258");
emailMessage.setText(unicode);

Everytime I send these bytes another 9 bytes reach the destination. How can I achieve this?

Receiver's string enconding doesn't matter to me. I'm not interested in how the characters display visually. I'm more concerned in the information, the hex value in the character.

David Wasser
  • 93,459
  • 16
  • 209
  • 274
Mickey Mouse
  • 107
  • 1
  • 11

1 Answers1

2

There's a relatively good explanation here or you can read RFC 1341 yourself.

Basically, only 7-bit US-ASCII characters are allowed (unencoded) in an email. Anything else (which includes your binary bytes) must be encoded using some encoding. This will convert your 9 bytes into more than 9 bytes (depending on what encoding is chosen).

Email (SMTP) is NOT a binary protocol. You can send binary data via email, but it is basically a hack.

Community
  • 1
  • 1
David Wasser
  • 93,459
  • 16
  • 209
  • 274