Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-11-14
8
Medium Priority
?
596 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 2000 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
Technology Partners: 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

Technology Partners: 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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

610 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