Results 1 to 5 of 5

Thread: Qt Messaging

  1. #1
    Join Date
    Sep 2011
    Posts
    3
    Qt products
    Qt4

    Default Qt Messaging

    Hi! I'm writing one program for sending email. I saw some examples and took next code from one
    Qt Code:
    1. QMessageService service;
    2. bool b;
    3.  
    4.  
    5. QString accountName("111@gmail.com");
    6. QMessage message;
    7. message.setType(QMessage::Email);
    8. message.setParentAccountId(QMessageAccountId(accountName));
    9.  
    10. QString to("222@gmail.com");
    11. QMessageAddress addr(QMessageAddress::Email,to);
    12. message.setTo(addr);
    13.  
    14. QString subject("first message");
    15. message.setSubject(subject);
    16.  
    17. QString text("Hello");
    18. message.setBody(text);
    19.  
    20. b = message.parentAccountId().isValid();
    21. if (service.send(message))
    22. {
    23. QMessageBox::information(0,tr("Success"),tr("Email sent successfully!"));
    24. hide();
    25. }
    26. else
    27. {
    28. QMessageBox::warning(0, tr("Failed"), tr("Unable to send message. Valid: %1").arg(b));
    29.  
    30. }
    To copy to clipboard, switch view to plain text mode 

    When i try to send message on my device it all the times say me "Unable to send message.Valid: 1". I don't know where can be mistake...should you give me any ideas?
    Last edited by high_flyer; 28th September 2011 at 15:38. Reason: code tags

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Messaging

    Looks like the parentAccountId you are setting is not valid.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Sep 2011
    Posts
    3
    Qt products
    Qt4

    Default Re: Qt Messaging

    should you tell me, what kind it must be? and b = 1 so it's valid, isn't it?

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Messaging

    and b = 1 so it's valid, isn't it?
    Yes, sorry, I read you post to quickly.
    This means that service.send() failed:
    Returns true if the operation can be initiated; otherwise returns false.
    I am don't really know about mobility.
    Maybe the problem is not in the code, but maybe the messaging service is not on, or something similar.
    Maybe some more experience mobility developers can help you more with that.

  5. #5
    Join Date
    Sep 2011
    Posts
    3
    Qt products
    Qt4

    Default Re: Qt Messaging

    thanks for advice

Similar Threads

  1. Replies: 0
    Last Post: 31st January 2011, 12:51
  2. Qt and Windows messaging
    By bnilsson in forum Qt Programming
    Replies: 1
    Last Post: 6th January 2010, 16:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.