login about faq

Hi, i´m trying to create an EML-File using chilkat.CkMail(). The results of the Outlook MAPI are Unicode, and the CkMail() Functions do not accept Unicode. So i have to encode the Outlook Results. But if i encode to "utf-8" all umlaute (ü,ä,ö) are replaced by strange signs in the resulting EML-File. I tried using "latin-1" but then i can´t encode Strings that contain Euro-Signs. Do you have any solution to bring unicode-strings in the EML-File?

my code atm:

def DecodeUnicode(pUnicodeString):
    for TryThis in ['latin_1', 'utf8']:
       try:
          Result = pUnicodeString.encode(TryThis)
          return Result
       except:
          pass
    return pUnicodeString

def CreateEMLFile(pItem)
    with tempfile.NamedTemporaryFile(suffix=".eml",prefix="TBTEMP_", delete=False) as nf:
       nf.close()
    newEmail = chilkat.CkEmail()
    newEmail.put_Subject(                   DecodeUnicode(pItem.Subject))
    newEmail.put_FromAddress(               DecodeUnicode(pItem.SenderEmailAddress))
    newEmail.put_FromName(                  DecodeUnicode(pItem.SenderName))
    newEmail.AddTo(                         DecodeUnicode(pItem.ReceivedByName),
                                            "test@test.de")                
    newEmail.AddPlainTextAlternativeBody(   DecodeUnicode(pItem.Body))
    newEmail.AddHtmlAlternativeBody(        DecodeUnicode(pItem.HTMLBody))
    newEmail.SaveEml(nf.name)
    return nf.name

asked Mar 19 '14 at 11:43

Danielr's gravatar image

Danielr
1111

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×7
×7
×3
×1
×1

Asked: Mar 19 '14 at 11:43

Seen: 1,092 times

Last updated: Mar 19 '14 at 11:43

powered by OSQA