[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Indy mail receive problem.

Posted on 2005-04-25
7
Medium Priority
?
1,612 Views
Last Modified: 2008-02-01
I am using Indy idSMTP and idPOP3 components to exchange data in an aplication from one location to another. Everything worked fine while the accounts were hosted on iPowerWeb, then we had to migrate the accounts and are now hosted on a local Microsoft Exchange server. The problem is when I try to receive a message it fails to decode (MIME encoded and base64 encoded attachments). I can not get body.text info (it contains header info) and what is even worse I can't get attached files out of the message. Indy recognises the file attachments as TIdText message parts.

I am using Delphi 7 and Indy 9.0 components.

The first message part is message body text (nothing in it for now) when I receive it I get this in the body property:

Content-Type: text/plain;
      charset="iso-8859-2"
Content-Transfer-Encoding: 7bit

The second part is supposed to be an attachment but it say it is an TIdText. I get this in the body:

Content-Type: application/octet-stream;
      name="TDOK.DB"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
      filename="TDOK.DB"

RgMAGAIQAQAAA... (the whole encoded file here)

Any sugestions would be much appreciated.
0
Comment
Question by:norc
  • 4
  • 3
7 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13861333
try changing the NoDecode property of your TidMessage ?
0
 
LVL 1

Author Comment

by:norc
ID: 13865338
I have it set to False all the time! Changing it would only make things worse since the message wouldn't even be parsed into message parts. NoEncode gets even worse. I managed to get it working using UU encoding but this does not solve the original problem. I suspect Exchange server has something to do with it but i can't figure out what!
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13869829
I had a problem with Indy 9, where the attachments were not being put into the TidAttachments correctly
which I attributed to a problem with the server I was talking to.
I also messed with the NoDecode/NoEncode and ended up instead doing a ReceiveRaw() then saving it to a temp file (making sure it had a final '.' )
and then reloading it from the file.
I never found the cause of the bug, but when I moved to Indy 10, I no longer had to do this.
Are you able to upgrade to the later indy components, or do you think this is a different issue?
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!

 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13869836
oh btw Indy 10 has quite a few changes so would mean a fair bit of rewriting to handle the new structures
0
 
LVL 1

Author Comment

by:norc
ID: 13883948
I trully don't know what the issue is but it only apeared when I moved the accounts to the Exchange server so it must have something to do with that. It is posible that the Exchange server restructures the message somehow so that Indy 9 can't handle them and the issue was fixed in Indy 10. I will not go into upgarding right now because I really don't see the need for it since I got it working. I will however try any suggestions that anyone will provide to fix this issue in Indy 9 with MIME encoding as soon as I find the time. I would apreciate a more detailed explanation of what you did with the temp file. Where are you checking for the final '.' and how?

Thx
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 1000 total points
ID: 13889094
this is what I was doing. it's not very pretty, but it did solve my particular problem. hope it does for you too.
I receive the message in raw format. check it has a final '.', then save it to file
I then reload the file from disk
At this point I save it as a unique name in a specified accounts directory, but you can do whatever you like with it
the CreateValidFilename function simply replaces dangerous chars with underscores. you probably wont need any of that part


            MSG.Clear;
            if POP.RetrieveRaw(MsgNumber, RawData) then
            begin
                if ( (RawData.Count > 0) and (RawData[Pred(RawData.Count)] <> '.') ) then
                  RawData.Add('.');
                ForceDirectories(InDirectory + AccountInfo[accountindex].Name + '\');
                RawData.SaveToFile(ExtractFilePath(Paramstr(0)) + '~temp.eml');

                try
                    Msg.LoadFromFile(ExtractFilePath(Paramstr(0)) + '~temp.eml', False);
                    UniqueFilename :=
                      FormatDateTime('yyyymmddhhnnsszzz', MSG.Date) + '_' +
                      MSG.Subject + '_' +
                      MSG.From.Text + '_' + MSG.UID;
                    UniqueFilename := CreateValidFilename(UniqueFilename);
                    onefilename := InDirectory + AccountInfo[accountindex].Name + '\' + uniquefilename +'.eml';
                except
                    on e:exception do
                    begin
                        UniqueFilename := FormatDateTime('yyyymmdd" "hhnnsszzz', Now) + '.eml';
                        UniqueFilename := CreateValidFilename(UniqueFilename);
                        onefilename := InDirectory + AccountInfo[accountindex].Name + '\' + uniquefilename +'.eml';
                    end;
                end;
                RawData.SaveToFile(onefilename);
                POP.Delete(MsgNumber);
                result := true;
            end;
0
 
LVL 1

Author Comment

by:norc
ID: 15533658
To be honest haven't still haven't tried it and as it turns out I don't need it anymore! I realize this took some time but I was busy and also changing jobs so I haven't found the time for it. Points awarded for effort though! Thx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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 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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

829 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