0
我遇到附加文件中包含unicode字符(主要是æ,ø和å)的問題,並在電子郵件中顯示爲「noname」。附件來自FileFields,因此它們是從系統連接的。使用unicode文件名的Attach_file顯示爲「noname」
這裏是消息功能的一部分:
msg = mail.EmailMessage()
msg.subject = u"%s" % message.subject
msg.from_email = "%s <%s>" % (message.author_name, message.author_email)
msg.content_subtype = "html"
msg.body = render_to_string("core/send_message_all.html", locals())
message_to = re.split(", |,", message.receiver)
if message.file1:
msg.attach_file(message.file1.file.path)
msg.send(fail_silently=False)
我使用Django 1.4.5。有誰知道我該如何解決這個問題?我曾經想過在上傳過程中使用文件名,但是之後我還需要塞住現有的文件。