0

I'm using the BeginReceive from Socket to receiving data from a e-mail.

I create a StringBuilder to put in the last position of the BeginReceive method, in object state

It works but StringBuilder was with strange characters. Instead of a basic portuguese name, who is in email (João Gelásio), it appears Jo=E3o Gel=E1sio

I can't understand if the problem is with StringBuilder configuration or I need to do some trick when reading the email with BeginReceive.

Can anyone help me?

Thanks in advance

Gelásio
  • 1,899
  • 1
  • 19
  • 18

1 Answers1

0

It works but StringBuilder was with strange characters. Instead of a basic portuguese name, who is in email (João Gelásio), it appears Jo=E3o Gel=E1sio

That looks like it's just a matter of the text being in quoted printable encoding. There should be headers specifying this.

Note that it has nothing to do with whether you're using async or synchronous APIs.

Ideally, use a dedicated mail API to handle POP3 instead of writing your own low-level handlers. It should cover all of this for you.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • I'm using a mail API to do this, but I thnink this is not cover. When I see the mail in mailbox everything is ok. – Gelásio Aug 28 '12 at 16:45
  • @Gelásio: If you're talking directly to the socket, that's really *not* using a mail API... or if it is, it's an insanely thin one. Yes, I'd expect it to be fine in the mailbox - because the mail client understands the protocol (including quoted printable) correctly. – Jon Skeet Aug 28 '12 at 16:46
  • I'm using this: http://www.koders.com/info.aspx?c=ProjectInfo&pid=7T61R6FGAWR5AG6AM1VETW6K1A&s=socket – Gelásio Aug 28 '12 at 16:47
  • @Gelásio: So why are you handling the socket directly? Does the API not do all of that for you? On a glance at it, it looks like it should be able to do all the parsing for you. – Jon Skeet Aug 28 '12 at 16:49
  • I'm just follow the code (debugging) to try find the problem and I stuck here in StartReceive method http://www.koders.com/csharp/fid0DABE2CB1FF7EDA1F5992642ABE4F28A1A5964D7.aspx?s=socket#L5 I have this exacte code – Gelásio Aug 28 '12 at 16:52
  • 1
    @Gelásio: That just shows it's not a good mail API, basically. I suggest you find a better one. – Jon Skeet Aug 28 '12 at 19:15