Re: Message with attachment puts attachment in body of mail

Giganews Newsgroups
Subject: Re: Message with attachment puts attachment in body of mail
Posted by:  Remy Lebeau \(Indy Team\) (no.spam@no.spam.com)
Date: Wed, 12 Dec 2007

"mojoala" <jwarr…@jimbishopcabinets.com> wrote in message
news:723712949940E340jwarr…@jimbishopcabinets.com...

> How do you overcome this?

You need to be more specific about what "this" is exactly.

> Upgraded to Delphi2007 and Indy 10

Which build of Indy 10, though?  If you are using the one that shipped with
D2007, then you are using a very old build, as D2007 shipped with the same
build that D2006 shipped with.

> attachments are always in some funky code in the body of the email.

Then your email data is likely in a format that Indy can't parse when
receiving emails, or you are not setting up the TIdMessage correctly when
sending emails.  Please show the actual raw email data.

> So how do we programmatically or property-wise fix this.

There is no way to answer that without more information first.

> Here is my code

Try this instead:

    function TDMJBCRoutines.fSetupEMailFiles(const InDirectory, InFileSpec :
String) : Boolean;
    var
        SearchRec: TSearchRec;
        Dir: String;
    begin
        Result := False;
        try
            with wsMsg do
            begin
                MessageParts.Clear;
                Dir := IncludeTrailingBackslash(InDirectory);
                if FindFirst(Dir + InFileSpec, faAnyFile and not
faDirectory, SearchRec) = 0 then
                try
                    repeat
                        TIdAttachmentFile.Create(MessageParts, Dir +
SearchRec.Name);
                        Result := True;
                    until FindNext(SearchRec) <> 0;
                finally
                    FindClose(SearchRec);
                end;
            end;
        except
            on E: Exception do
            begin
                Result := False;
                ShowMessage('Attachment files FAILED!!!');
            end;
        end;
    end;

Gambit

Replies

None

In response to

Message with attachment puts attachment in body of mail posted by mojoala on Wed, 12 Dec 2007