Solved

SaveToFile (and LoadfromFile) do not work in Indie9/D5 environment.  Why?

Posted on 2006-11-14
8
588 Views
Last Modified: 2010-04-05
I have been creating a custom email client for a customer using Indy9 and D5.  All is well except that I need to be able to save Msg objects locally for review after deleting them from the server.  Using the TidMessage SaveToFile and LoadFromFile methods almost works - except if the message has an attachment.  If that is the case, the body of the message is not available after retrieving the msg from a file.  

I also tried simply saving to a stream - clearing the msg then immediately rereading the stream - I get the same results.

Is this a known problem with Indy9?  If so does Indy10 have it fixed?  Or is there something special that needs to be done with a msg read from a file or stream?

Thanks in advance - (example code would be a help)
0
Comment
Question by:DMTrump
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
8 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 17943614
change the IdMessage1.NoDecode property
0
 

Author Comment

by:DMTrump
ID: 17943739
I JUST figured that out myself (that I needed to save the message undecoded - but still didn't know how to do it)  Thanks - I'll give it a try -  I may have further questions so I'll leave the question open for now.

This may be the easiest 500 points you've ever earned!  
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 500 total points
ID: 17943762
yeah, may as well get you 500 pts worth.
eg. Indy 9 does not always put the final dot ( . ) at teh end of the file
so if you were to Save it as "temp.eml"
OE, outlook etc would not be able to open it (by just double clicking on it)
so you may find you need to stick a dot at the end yourself.
Not sure if *all* versions of Indy 9 had this issue, but probably your next hurdle (was mine)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:DMTrump
ID: 17943830
I see that if the email has an attachment, I need to save it with IdMessage1.NoDecode:=true; but if there is no attachment IdMessage1.NoDecode:=false;  If that is so, what is the easiest most reliable way to test for multipart?   Must I retreive the message and decode it to look for MessageParts.count - then if there is more than 1, close the message, set nodecode:=true, retreive it again before saving it?



0
 

Author Comment

by:DMTrump
ID: 17943867
That bit about the final dot is good to know - in this case ONLY indie will ever reopen the file - but I'll do it anyway.

I've GOT to spend some time studying Indy before the next time I need it in a hurry!  I'm getting BDS2006 soon - maybe then!
0
 

Author Comment

by:DMTrump
ID: 17943912
Looks like my copy of Indy9 is putting the dot on.  I was able to open a saved file in OE without problem.
0
 

Author Comment

by:DMTrump
ID: 17944693
I got everything figured out - just for anybody else looking at this here is my conclusion:

You must always save to a file with NoDecode set to true.  However, when you read the file - set nodecode to false, of course, and then make sure that after adding Any messageparts to your text display that are TIdText, you must also add in the msg.body.  that takes care of messages that are <not> multipart.  If you fail to do that, messages that do not have attachments will appear blank.

Thanks to TheRealLoki for putting me on the right track!
0
 

Author Comment

by:DMTrump
ID: 17944710
I forgot to say above that you need to test for your memo being empty before adding the body - otherwise you will get the "this is a multipart..." message added in.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question