NetTalk Central

Author Topic: Non-ASCII email subjects and attachment file names  (Read 7170 times)

vklemet

  • Newbie
  • *
  • Posts: 30
    • View Profile
Non-ASCII email subjects and attachment file names
« on: June 06, 2013, 09:51:16 PM »
Hello,

Is there a simple way in NetTalk to include non-ASCII characters to a subject-field of and to a file name of an attachment when sending emails? The way it shoud be done is defined in RFC 2047 (http://tools.ietf.org/html/rfc2047).

It almost works with the subject field with following code:

Code: [Select]
ThisSendEmail.Subject = '=?iso-8859-1?Q?' & NetQuotedPrintableEncode (CLIP(EmailSubject),len1,linelen) & '?='
But NetQuotedPrintableEncode doesn't seem to encode space-characters, so the result is not compliant with RFC 2047.

Attachment name seems to be more difficult to set. The only way I have found is to change the ProcessAttachments routine in NetEmail.clw. However, if I do the change and use Nettalk for downloading and saving attachments sent with the changed routine will mess up the saved file name. Saving seems to work fine with other clients. As the same messages need to be handled with Nettalk and other email-clients with non-ascii characters correctly showing, some hints would be greatly appreciated!

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: Non-ASCII email subjects and attachment file names
« Reply #1 on: June 06, 2013, 10:44:22 PM »
Hi vklemet,

I had a problem with the special danish characters. So what I did is this:

Somewhere before the ThisSendEmail.SendMail() I put this line of code:
ThisSendEmail.OptionsMimeTextCharset = 'iso-8859-1'

Then you don't have to worry about explicitely encoding the subject, then the text etc.

Haven't seen the problem with attached file names so can't help here (but perhaps that's also taken care of when setting the charset?).

Peter

vklemet

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Non-ASCII email subjects and attachment file names
« Reply #2 on: June 06, 2013, 10:50:17 PM »
Hi Peter, and thanks for your reply,

I already use the ThisSendEmail.OptionsMimeTextCharset = 'iso-8859-1' before ThisSendEmail.SendMail() and it works great with the actual content of the email (text and html), but it doesn't seem to have affect to the subject and attachment filename.

-Vesa-


estadok

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
    • EstaSoft
    • Email
Re: Non-ASCII email subjects and attachment file names
« Reply #3 on: June 07, 2013, 12:01:25 AM »
Hi vklemet,

Try this

ThisSendEmail.Subject = '=?iso-8859-1?Q?' & p_web.Base64Encode(CLIP(EmailSubject)) & '?='

About attachments. Did you changed charset of saved file on save?
« Last Edit: June 07, 2013, 12:05:40 AM by estadok »
Clarion 9.0.10376
NetTalk 7.26
SecWin 6.25
StringTheory 1.92

vklemet

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Non-ASCII email subjects and attachment file names
« Reply #4 on: June 07, 2013, 01:08:28 AM »
Hi estadok, and thanks for your reply.

Ok, the code clip you posted works, with few tweaks because the current project is not a WebServer project (also replaced Q with B, as RFC-document defines):

Code: [Select]
len1 = LEN(CLIP(EmailSubject))
ThisSendEmail.Subject     = '=?iso-8859-1?B?' & CLIP(NetBase64Encode(CLIP(EmailSubject),len1)) & '?='

Do you mean did I change the filename charset when saving the attachment? The file itself is not a text file. I did not process the file name in any way when saving the file with nettalk client. I was hoping that nettalk would do it, as it is quite common way to handle attachment names, Well, I guess DIY is the best way then :)

-Vesa-

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11193
    • View Profile
Re: Non-ASCII email subjects and attachment file names
« Reply #5 on: June 09, 2013, 10:55:46 PM »
I have added an EncodedWordEncode method to StringTheory.
http://www.capesoft.com/docs/StringTheory/StringTheory.htm#stEncodedWordEncode
That should made this a bit easier.

cheers
Bruce

vklemet

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Non-ASCII email subjects and attachment file names
« Reply #6 on: August 12, 2013, 10:28:52 PM »
Thanks Bruce!

 I'll update my StringTheory to latest version.

-Vesa-

vklemet

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Non-ASCII email subjects and attachment file names
« Reply #7 on: August 13, 2013, 03:24:45 AM »
Okay, got this finally done.

I added a procedure to NetEmail.clw which handles the encoding of the subject and attachment name using StringTheory and is called from ProcessAttachments routine when setting the name of the attachment and from my program code when setting the subject of the message.

Bruce, would it be possible to include the encoding option for both the subject and the attachment filenames to future releases of NetTalk, so that the modifying the NetEmail.clw would not be necessary?

-Vesa-

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11193
    • View Profile
Re: Non-ASCII email subjects and attachment file names
« Reply #8 on: August 13, 2013, 05:14:13 AM »
hi Vesa,

Yes, if you send me your altered file, I can see about merging it into the main release.

cheers
Bruce