Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. India
  4. To send HTML format Mail using QTCPSocket
Qt 6.11 is out! See what's new in the release blog

To send HTML format Mail using QTCPSocket

Scheduled Pinned Locked Moved India
4 Posts 2 Posters 3.1k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    ATHEES
    wrote on last edited by
    #1

    i am using qt4
    i had completed to send a Plain text
    now i need to send HTML format text
    i had send the HTML content that is without any header any header is given for eg.. To , From and Subject
    only the Body Content
    i attached my coding down plz give some tips

    //////////////////////////
    Smtp::Smtp( const QString &from, const QString &to, const QString &subject , const QString &body ,const QString &address,int port)
    {
    socket = new QTcpSocket(this);

    connect( socket, SIGNAL(readyRead()), this, SLOT( readyRead() ) );
    
    connect( socket, SIGNAL( connected()), this, SLOT( connected() ) );
    
    connect(socket, SIGNAL(disconnected()), this,SLOT(disconnected()));
    

    message = "To: " + to + "\n";

    message.append("From: " + from + "\n");

    message.append("Subject: " + subject + "\n");

    //Let's intitiate multipart MIME with cutting boundary "frontier"
    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/html\n\n" );

    message.append(body);

    message.append("\n\n");

    message.append( "- -frontier- -\n" );

    message.replace( QString::fromLatin1( "\n" ), QString::fromLatin1( "\r\n" ) );

    message.replace( QString::fromLatin1( "\r\n.\r\n" ),QString::fromLatin1( "\r\n..\r\n" ) );

    this->from = from;

    rcpt = to;

    state = Init;

    socket->connectToHost( address,port);//"172.17.72.36", 25);

    t = new QTextStream( socket );

    if(socket->waitForConnected ( 30000 ))

    {qDebug("connected"); }

    }

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Please use @ to wrap your code. It is very difficult to read it if it is not properly displayed. Do you set that this is text/html email at the header?

      http://anavi.org/

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ATHEES
        wrote on last edited by
        #3

        I had placed the header Part correctly

        OK THANKS..

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leon.anavi
          wrote on last edited by
          #4

          [quote author="$ATHEES" date="1378357142"]I had placed the header Part correctly

          OK THANKS..

          [/quote]

          You are welcome. Please edit the title and add prefix [SOLVED].

          http://anavi.org/

          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