Solved

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

Posted on 2006-11-14
8
567 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
  • 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
 

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now