cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2199
Views
0
Helpful
7
Replies

Cisco TCL Other Language support

peraocompany
Level 1
Level 1

Hello I need some help. I write TCL script for IOS. Default script in ANSII coding format.

in script body I need use other language message:

append mail_pre "Subject: Информация\n\n"

And I receive mail with not readable value.

If I change coding for file like UTF-8 IOS get error, and not accept script.

Can I have way to use other language in tcl script?

1 Accepted Solution

Accepted Solutions

Here is where you need additional headers to specify the MIME encoding.  For example:

append mail_pre "MIME-Version: 1.0\r\n"
append mail_pre "Content-Type: text/plain; charset=\"UTF-8\"\r\n"

View solution in original post

7 Replies 7

Joe Clarke
Cisco Employee
Cisco Employee

I don't think it's the encoding of the script that's the problem.  I think you need to specify the encoding of the message in the SMTP envelope.  Have a look at http://stackoverflow.com/questions/10752853/php-mailfrom-cyrrilic-encoding .  This gives you an example of how to adjust the headers in general.  You can do this same thing in Tcl by adding your headers after the default set of email headers.

For Base64 encoding, use ::base64::encode in EEM Tcl:

set b64 [::base64::encode $mySubject]

Hello Joseph, thonk you.

I try do construction like this:

set line_b64 [::base64::encode $line]

set mail_pre "Mailservername: user:pass@smtp.server.com\n"

append mail_pre "From: mail@domain.com\n"

append mail_pre "To: tomail@domain.com\n"

append mail_pre "Cc: from@domain.com\n"

append mail_pre "Subject:test\n"

append mail_pre "Date: $syslog_time_s\n"

append mail_pre "MIME Version: 1.0 \n"

append mail_pre "Content-Type: text/plain\n"

append mail_pre "Content-Transfer-Encoding: Base64\n"

append mail_pre "$line_b64\n"

set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]

In email I see line in b64 no cirilic format.

You're not doing what the article says to do.  I'm not sure what you're trying to accomplish here.  If you want to have a subject with Cyrillic characters, do:

...

append mail_pre "Subject: =?UTF-8?B?[::base64::encode Информация]?=\r\n"

...

Thank you Joseph. In my case if I use =?UTF-8?B?[::base64::encode Информация]?=\r\n"

It not work in Microsoft Outlook, but work on other (like iphone)

If i use WIN-1251 charset it fork fine in Outlook.

"Subject: =?windows-1251?B?[::base64::encode Информация]?=\r\n"

Can posable change charset  for email body?

In subject all ok, in email body i have no readeble value.

I use construction now?

 

set mail_pre "Mailservername: user:pass@smtp.server.com\n"

append mail_pre "From: mail@domain.com\n"

append mail_pre "To: tomail@domain.com\n"

append mail_pre "Cc: from@domain.com\n"

append mail_pre "Subject: =?windows-1251?B?[::base64::encode Информация

]?=\r\n"

append mail_pre "Date: $syslog_time_s\n"

append mail_pre "=?windows-1251?B?[::base64::encode Информация]?=\r\n"

set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]

Here is where you need additional headers to specify the MIME encoding.  For example:

append mail_pre "MIME-Version: 1.0\r\n"
append mail_pre "Content-Type: text/plain; charset=\"UTF-8\"\r\n"

Thank you Joseph.