Garbled text when constructing emails with vmime

Posted by Klaus Fiedler on Stack Overflow See other posts from Stack Overflow or by Klaus Fiedler
Published on 2010-03-13T23:38:19Z Indexed on 2010/03/13 23:45 UTC
Read the original article Hit count: 284

Filed under:
|
|
|
|

Hey, my Qt C++ program has a part where it needs to send the first 128 characters or so of the output of a bash command to an email address. The output from the tty is captured in a text box in my gui called textEdit_displayOutput and put into my message I built using the Message Builder ( the object m_vmMessage ) Here is the relevant code snippet:

m_vmMessage.getTextPart()->setCharset( vmime::charsets::US_ASCII ); m_vmMessage.getTextPart()->setText( vmime::create < vmime::stringContentHandler > ( ui->textEdit_displayOutput->toPlainText().toStdString() ) ); vmime::ref < vmime::message > msg = m_vmMessage.construct(); vmime::utility::outputStreamAdapter out( std::cout ); msg->generate( out );

Giving bash 'ls /' and a newline makes vmime give terminal output like this:

ls /=0Abin    etc=09   initrd.img.old  mnt=09 sbin=09  tmp=09   vmlinuz.o=
ld=0Aboot   farts=09   lib=09=09   opt=09 selinux  usr=0Acdrom  home=09  =
 lost+found=09   proc  srv=09  var=0Adev    initrd.img  media=09   root  =

Whereas it should look more like this:

ls /
bin    etc     initrd.img.old  mnt   sbin     tmp      vmlinuz.old
boot   farts       lib         opt   selinux  usr
cdrom  home    lost+found      proc  srv      var
dev    initrd.img  media       root  sys      vmlinuz
18:22>

How do I encode the email properly? Does vmime just display it like that on purpose and the actual content of the email is ok?

© Stack Overflow or respective owner

Related posts about vmime

Related posts about qt