?
Solved

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

Posted on 2006-11-14
8
Medium Priority
?
591 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 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