Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to send mails with polish letters?
QtWS25 Last Chance

How to send mails with polish letters?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 400 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TomNow99
    wrote on last edited by
    #1

    Hello,

    I have the code from here:

    https://github.com/xcoder123/SimpleSmtp_SSL_QT5/tree/master/smtp_attachements

    I would like to send mails with polish letters. I have very strange result. I talk about bodies:

    What I send: ĄĘĆŻŹ
    What I receive: • ∆Øè

    What I send: ĄĘĆŁÓŃŚ
    What I receive: ¥تئ£سرŒ

    What I send: błąd
    What I receive: b彻d

    What I send: Błędy, które otrzymałem to
    What I receive: Błędy, które otrzymałem to

    In the last example I get what I want.

    I try change:

        message.append( "Content-Type: text/plain\n\n" );
        message.append(body);
        message.append("\n\n");
    

    to:

        message.append( "Content-Type: text/plain; charset=UTF-8\n\n" );
        message.append(body);
        message.append("\n\n");
    

    But I get the same values ( not good result ).

    jsulmJ 1 Reply Last reply
    0
    • T Offline
      T Offline
      TomNow99
      wrote on last edited by TomNow99
      #5

      @jsulm
      message is QString. This is a argument in sendMail(), which I show in the previous post.

      Where I receive mail? I don't understand the question. I send it to my gmail account.

      EDIT

      @jsulm I think I have solution, but I check this only one time. But I have other question to you. My solution:
      I change:

              *t << message << "\r\n.\r\n";                         //// t is QTextStream
              t->flush();
              state = Quit;
      

      to:

              auto x = t->codec();
              t->setCodec("UTF-8");
              *t << message << "\r\n.\r\n";
              t->flush();
              t->setCodec(x);
              state = Quit;
      

      And the question: what with this "x" variable? I have to delete it after setCodec()?

      1 Reply Last reply
      0
      • T TomNow99

        Hello,

        I have the code from here:

        https://github.com/xcoder123/SimpleSmtp_SSL_QT5/tree/master/smtp_attachements

        I would like to send mails with polish letters. I have very strange result. I talk about bodies:

        What I send: ĄĘĆŻŹ
        What I receive: • ∆Øè

        What I send: ĄĘĆŁÓŃŚ
        What I receive: ¥تئ£سرŒ

        What I send: błąd
        What I receive: b彻d

        What I send: Błędy, które otrzymałem to
        What I receive: Błędy, które otrzymałem to

        In the last example I get what I want.

        I try change:

            message.append( "Content-Type: text/plain\n\n" );
            message.append(body);
            message.append("\n\n");
        

        to:

            message.append( "Content-Type: text/plain; charset=UTF-8\n\n" );
            message.append(body);
            message.append("\n\n");
        

        But I get the same values ( not good result ).

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @TomNow99 From where and how do you get the text you want to send?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • T Offline
          T Offline
          TomNow99
          wrote on last edited by TomNow99
          #3

          @jsulm Yeah, I forget about that. My app is GUI app And I do something like that:

          The messageEdit is QPlainTextEdit. I execute function sendMail when I click on button:

          smtp->sendMail("abc@onet.pl", "def@gmail.com" , subjectEdit->text().isEmpty()?"brak tematu":subjectEdit->text(), messageEdit->toPlainText(), files );
          

          next I go to sendMail function, which looks like:

          void sendMail(const QString &from, const QString &to, const QString &subject, const QString &body, QStringList files)
          

          And in this function I have:

              message = "To: " + to + "\n";
              message.append("From: " + from + "\n");
              message.append("Subject: " + subject + "\n");
              message.append("MIME-Version: 1.0\n");
              message.append("Content-Type: multipart/mixed; boundary=frontier\n\n");
              message.append( "--frontier\n" );
              message.append( "Content-Type: text/plain; charset=UTF-8\n\n" );
              message.append(body);
              message.append("\n\n");
          

          And below I have:

          else if ( state == Body && responseLine == "354" )
              {
                  *t << message << "\r\n.\r\n";
                  t->flush();
                  state = Quit;
              }
          

          t is QTextStream

          EDIT
          So I get body from QPlainTextEdit using toPlainText().

          jsulmJ 1 Reply Last reply
          0
          • T TomNow99

            @jsulm Yeah, I forget about that. My app is GUI app And I do something like that:

            The messageEdit is QPlainTextEdit. I execute function sendMail when I click on button:

            smtp->sendMail("abc@onet.pl", "def@gmail.com" , subjectEdit->text().isEmpty()?"brak tematu":subjectEdit->text(), messageEdit->toPlainText(), files );
            

            next I go to sendMail function, which looks like:

            void sendMail(const QString &from, const QString &to, const QString &subject, const QString &body, QStringList files)
            

            And in this function I have:

                message = "To: " + to + "\n";
                message.append("From: " + from + "\n");
                message.append("Subject: " + subject + "\n");
                message.append("MIME-Version: 1.0\n");
                message.append("Content-Type: multipart/mixed; boundary=frontier\n\n");
                message.append( "--frontier\n" );
                message.append( "Content-Type: text/plain; charset=UTF-8\n\n" );
                message.append(body);
                message.append("\n\n");
            

            And below I have:

            else if ( state == Body && responseLine == "354" )
                {
                    *t << message << "\r\n.\r\n";
                    t->flush();
                    state = Quit;
                }
            

            t is QTextStream

            EDIT
            So I get body from QPlainTextEdit using toPlainText().

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @TomNow99 What is "message". Is it QString?
            Where do you receive the mail and what encoding is set there?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • T Offline
              T Offline
              TomNow99
              wrote on last edited by TomNow99
              #5

              @jsulm
              message is QString. This is a argument in sendMail(), which I show in the previous post.

              Where I receive mail? I don't understand the question. I send it to my gmail account.

              EDIT

              @jsulm I think I have solution, but I check this only one time. But I have other question to you. My solution:
              I change:

                      *t << message << "\r\n.\r\n";                         //// t is QTextStream
                      t->flush();
                      state = Quit;
              

              to:

                      auto x = t->codec();
                      t->setCodec("UTF-8");
                      *t << message << "\r\n.\r\n";
                      t->flush();
                      t->setCodec(x);
                      state = Quit;
              

              And the question: what with this "x" variable? I have to delete it after setCodec()?

              1 Reply Last reply
              0
              • T Offline
                T Offline
                TomNow99
                wrote on last edited by
                #6
                This post is deleted!
                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved