Spaces in mail.subject

  1. 5 years ago

    Michael B

    4 Mar 2015 Pre-Release Testers Haan, Germany

    Hi,

    i encode my mail.subject quoted-printable. but when i send a subject with spaces like e.g. "Hello from Xojo", i get a Warning in my Mail-Header which says:

    BAD_ENC_HEADER Message has bad MIME encoding in the header

    This only appears when having spaces in the subject.

    This is the code i use to encode the subject:

    mail.Subject = "=?iso-8859-1?q?" + EncodeQuotedPrintable(ConvertEncoding(txtSubject.Text, Encodings.ISOLatin1)) + "?="

    Any ideas how i get this working with spaces?

    Michael

  2. Albin K

    4 Mar 2015 Europe (Sweden)

    Hmm, never seen EncodeQuotedPrintable before.
    Anyway, try EncodeURLComponent on the subject. It will convert all spaces into "%20" and might work.

  3. Michael B

    5 Mar 2015 Pre-Release Testers Haan, Germany

    Hi Albin,

    tried your suggestion:

    mail.Headers.AppendHeader("Content-Type", "text/plain; charset=utf-8")
    mail.Headers.AppendHeader("Content-Transfer-Encoding", "quoted-printable")
    mail.Subject = "=?utf-8?q?" + EncodeURLComponent(txtSubject.Text) + "?="

    but the result looks like this:

    Test%20mit%20%C3%BC%20ohne%20Anhang

    Are there any other steps i have missed?

  4. Edited 5 years ago

    If I were you, and if I understand you correctly, I would make it like so:

    Let's say you have an "Email Us" Button.

    On Action:

    ShowURL("mailto:address@domain.com?subject=Subject%20Line%20Here")

    Note: The %20 is equal to a space in the subject line

  5. Michael B

    5 Mar 2015 Pre-Release Testers Haan, Germany

    yes, maybe this would be the easiest way. after working hours and hours on the right encodings with or without attachments, it seems, that xojos mail functions are not made or at least not well documented for sending not us/en mails.

    But i want to send the mail from within my app.

    I'll take your suggestion as last choice, when all other encoding-suggestions have failed, ok?

  6. @Michael B t i want to send the mail from w

    Do what ever works for you! Thank you for the response.

    That code worked for me, but I may have had a different objective than you.

  7. Michael B

    5 Mar 2015 Pre-Release Testers Haan, Germany

    Is it possible to handle a attachment in the mailto as well?

  8. Norman P

    5 Mar 2015 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...
    Edited 5 years ago

    https://tools.ietf.org/html/rfc2368
    replaced by http://tools.ietf.org/html/rfc6068

    @Michael B Is it possible to handle a attachment in the mailto as well?

    No

  9. Michael B

    5 Mar 2015 Pre-Release Testers Haan, Germany

    ok. no attachments with mailto.

    I also read, that the mailto has a limitation of 2000 characters, which can be to small for some of my mails. Is this correct?

  10. Bob C

    5 Mar 2015 Beaverton, Oregon and sometime...
    Edited 5 years ago

    @Michael B mail.Headers.AppendHeader("Content-Type", "text/plain; charset=utf-8") mail.Headers.AppendHeader("Content-Transfer-Encoding", "quoted-printable") mail.Subject = "=?utf-8?q?" + EncodeURLComponent(txtSubject.Text) + "?="

    Try changing the last line to:

    mail.Subject = "=?utf-8?q?" + EncodeQuotedPrintable(ConvertEncoding(txtSubject.Text, Encodings.UTF8)) + "?="

    In your first post above you are using Latin1 in a UTF-8 email. That won't work you need to keep your encodings consistent.

  11. Michael B

    5 Mar 2015 Pre-Release Testers Haan, Germany

    when i use this, do i have to convert or encode the body? And it which way?

    This is what i get in the received mail-header:

    Date: Thu, 5 Mar 2015 19:29:38 +0100
    Subject: =?utf-8?q?Test mit =C3=BC?=
    From: michael@bytemasters.de
    To: michael@bytemasters.de
    Message-ID: <050315.192938@vwp1446.webpack.hosteurope.de>
    Mime-Version: 1.0
    Content-Transfer-Encoding: quoted-printable
    Content-type: text/plain; charset=utf-8
    X-bounce-key: webpack.hosteurope.de;michael@bytemasters.de;1425580178;95b8e9dd;
    X-HE-Virus-Scanned: Yes
    X-HE-Spam-Level: /
    X-HE-Spam-Score: 0.0
    X-HE-Spam-Report: Content analysis details:   (0.0 points)
      pts rule name              description
     ---- ---------------------- --------------------------------------------------
      0.0 BAD_ENC_HEADER         Message has bad MIME encoding in the header
    Envelope-to: mail@uniformis.de
    
    Hallo=2E=0A=0Avia xojo-mail=2E

    The Message has bad MIME encoding in the header occurs only when using spaces in the subject.

  12. Beatrix W

    5 Mar 2015 Pre-Release Testers, Third Party Store Europe (Germany)

    Encodings in body and subject can be totally different. I think that you are still learning about encodings, which is causing the problems.

  13. Albin K

    5 Mar 2015 Europe (Sweden)

    I have a WE app that send an email and my subject actually just looks like this and it works just fine. And yes, there are spaces in the subject :)

    mail.subject = DefineEncoding(emailSubject, Encodings.UTF8)
  14. Michael B

    6 Mar 2015 Pre-Release Testers Haan, Germany

    Yes, you are right, Beatrix. I'm still learning about encodings. I now have implemented both solutions (mail with xojo-socket and the mailto-way). The user can choose his preferred solutions within the app-settings.

    Albin, my code works, that is not my problem. I just want to get rid of the warning in the header like i have written before. Have you checked your mail-headers when sending a mail to yourself?

  15. Beatrix W

    6 Mar 2015 Pre-Release Testers, Third Party Store Europe (Germany)

    :-)

    The spaces ain't the problem in the subject but the umlauts are. The way to encode the subject is rather confusing.

  16. Michael B

    6 Mar 2015 Pre-Release Testers Haan, Germany

    A space letter causes the warning in the mail-header. Tried this several times.

  17. Michael B

    6 Mar 2015 Pre-Release Testers Haan, Germany

    Just to clear things up.

    I send one mail with umlaut and spaces and get this mail-header:

    Message-ID: <060315.094126@vwp1446.webpack.hosteurope.de>
    Mime-Version: 1.0
    Content-Transfer-Encoding: quoted-printable
    Content-type: text/plain; charset=utf-8
    X-bounce-key: webpack.hosteurope.de;michael@bytemasters.de;1425631287;d3420b1f;
    X-HE-Virus-Scanned: Yes
    X-HE-Spam-Level: /
    X-HE-Spam-Score: 0.0
    X-HE-Spam-Report: Content analysis details:   (0.0 points)
      pts rule name              description
     ---- ---------------------- --------------------------------------------------
      0.0 BAD_ENC_HEADER         Message has bad MIME encoding in the header
    Envelope-to: michael@bytemasters.de
    
    Test mit Umlauten und Leerzeichen im Subject=2E=0A=0A=C3=A4=C3=B6=C3=
    =BC=C3=9F

    then i send another mail with umlaut but without spaces and get this mail-header:

    Message-ID: <060315.094258@vwp1446.webpack.hosteurope.de>
    Mime-Version: 1.0
    Content-Transfer-Encoding: quoted-printable
    Content-type: text/plain; charset=utf-8
    X-bounce-key: webpack.hosteurope.de;michael@bytemasters.de;1425631379;91d792f4;
    X-HE-Virus-Scanned: Yes
    X-HE-Spam-Level: /
    X-HE-Spam-Score: 0.0
    X-HE-Spam-Report: Content analysis details:   (0.0 points)
      pts rule name              description
     ---- ---------------------- --------------------------------------------------
    Envelope-to: mail@uniformis.de
    
    Test mit Umlauten und keinen Leerzeichen im Subject=2E=0A=0A=C3=A4=C3=
    =B6=C3=BC=C3=9F

    As you can see, there is a BAD_ENC_HEADER in the mail-header with spaces.

or Sign Up to reply!