Board index » delphi » Where did the email header go?

Where did the email header go?

Is Indy modifying the headers of the email? Everytime I view the headers of
an email received trough Indy (sent using OE), there is an 'X-something:
Indy 9' header, which is not in the original email.

Also, even more important: Indy eats the 'Content-ID' from attachments. I
need this badly, otherwise I can't parse HTML emails with inline images...

I'm using Indy 9.0.2b. I did modify IdMessageCodeMIME to stop crashing when
it receives a message which is not complete (so I could do the TOP X 100
command), but that has nothing to do with the headers...

Is this a bug in the decoder? Is there a way to retrieve the unmodified
headers?

Thanks in advance,

Mark van Renswoude

 

Re:Where did the email header go?


The ContentID problem is fixed:

Added to IdMessage.pas:

--------------------
  protected
    FContentDisposition: string;
    FFileIsTempFile: boolean;
    FFileName: TFileName;
    FCID: string;                                <= ADDED
    //
    function GetContentDisposition: string;
    procedure SetContentDisposition(const Value: string);
  public

            * cut *

    property FileName: TFileName read FFileName write FFileName;
    property ContentID: string read FCID write FCID;
<= ADDED
  end;
--------------------

Added to IdMessageClient.pas:

--------------------
  function ProcessAttachment(ADecoder: TIdMessageDecoder):
TIdMessageDecoder;

            * cut *

      with TIdAttachment.Create(AMsg.MessageParts) do
      begin
        ContentType := ADecoder.Headers.Values['Content-Type'];
        ContentTransfer :=
ADecoder.Headers.Values['Content-Transfer-Encoding'];

        ContentID := ADecoder.Headers.Values['Content-ID'];
<= ADDED

        Filename := ADecoder.Filename;
        StoredPathname := LTempPathname;
      end;
      ADecoder.Free;
    finally
      FreeAndNil(LDestStream);
    end;
  end;

--------------------

Now I need only one more thing:  the raw headers of the email.

And one more comment: why doesn't Indy remove it's temp files? There are
over 500 IndXX.tmp files in C:\Documents and Settings\*username*\Local
Settings\Temp !

"M. van Renswoude" <m...@no-spam.x2software.net> wrote in message
news:3c454c04_1@dnews...
Is Indy modifying the headers of the email? Everytime I view the headers of
an email received trough Indy (sent using OE), there is an 'X-something:
Indy 9' header, which is not in the original email.

Also, even more important: Indy eats the 'Content-ID' from attachments. I
need this badly, otherwise I can't parse HTML emails with inline images...

I'm using Indy 9.0.2b. I did modify IdMessageCodeMIME to stop crashing when
it receives a message which is not complete (so I could do the TOP X 100
command), but that has nothing to do with the headers...

Is this a bug in the decoder? Is there a way to retrieve the unmodified
headers?

Thanks in advance,

Mark van Renswoude

Re:Where did the email header go?


Better yet... Why can't the option of NOT using temp files, or at least
WHERE to put them be made available?
Quote
> And one more comment: why doesn't Indy remove it's temp files? There are
> over 500 IndXX.tmp files in C:\Documents and Settings\*username*\Local
> Settings\Temp !

Re:Where did the email header go?


Hello there

"M. van Renswoude" <m...@no-spam.x2software.net> schrieb im Newsbeitrag
news:3c456826$1_2@dnews...

Quote
> And one more comment: why doesn't Indy remove it's temp files? There are
> over 500 IndXX.tmp files in C:\Documents and Settings\*username*\Local
> Settings\Temp !

When I have written my pop downloader, I do the following:

with this I get the TempDirectory !!

function TPOPThread.TempDirectory: string;
begin
{$IFDEF LINUX}
  { TODO 3 : User should be able to set temp directory }
  Result := '/usr/tmp/';
{$ELSE}
  SetLength(Result, 300);
  GetTempPath(300, PChar(Result));
  SetLength(Result, StrLen(PChar(Result)));
{$ENDIF}
end;

and then

        for i := 1 to MessageCount do begin
          EMail.Clear;
            Pop3.Retrieve(i, EMail);
          if Email.MessageParts.Count > 0 then begin
            for p := 0 to EMail.MessageParts.Count - 1 do begin
              if (EMail.MessageParts.Items[p] is TIdText) then begin
                [ ... ]
                with EMail.MessageParts[p] as TIdAttachment do begin
                  // Message part is an attachment
                  AttachmentFileName := TempDirectory + FileName;

       // -----> I just check if there is a file with the same name
available, then I delete it

                  if FileExists(AttachmentFileName) then
                    deletefile(AttachmentFileName); // einfach zur
Sicherheit ;-)
                  SaveToFile(AttachmentFileName);
                  if not qAttachment.Active then
                    qAttachment.Open;
                  qAttachment.Append;
                  try
                    [... do what you want with the attachment ]
                    if not deletefile(AttachmentFileName) then
                          // showMessage(AttachmentFileName + ' could not be
deletet!');
                  except
                    // do exception handling
                  end;
                end;
        [.....]

Other Threads