Re: File Attachment in Indy 10 Mail Client demo is not working

Giganews Newsgroups
Subject: Re: File Attachment in Indy 10 Mail Client demo is not working
Posted by:  Chuck Belanger (phytote…@lanset.com)
Date: Fri, 11 Mar 2005

Thank you for the reply:

> Please elaborate.  What does your actual code look like?

This is taken from my code, but it is exactly what the demo looks like:

procedure TfrmMessageEditor.btnAttachmentClick(Sender: TObject);
begin
  if OpenDialog1.Execute then
      begin
//        TIdAttachment.Create(IdMsgSend.MessageParts, OpenDialog1.FileName);
//        TIdAttachment should NO LONGER be used. Use IdAttachmentFile or
IdAttachmentFile instead.
        TIdAttachmentFile.Create(IdMsgSend.MessageParts, OpenDialog1.FileName);

        ResetAttachmentListView;
      end;
end;

procedure TfrmMessageEditor.ResetAttachmentListView;
var li: TListItem;
  idx: Integer;
begin
  lvFiles.Items.Clear;
  for idx := 0 to Pred(IdMsgSend.MessageParts.Count) do
      begin
        li := lvFiles.Items.Add;
        if IdMsgSend.MessageParts.Items[idx] is TIdAttachmentFile then
            begin
              li.ImageIndex := 0;
              li.Caption :=
TIdAttachmentFile(IdMsgSend.MessageParts.Items[idx]).Filename;

li.SubItems.Add(TIdAttachmentFile(IdMsgSend.MessageParts.Items[idx]).ContentType);

            end
        else
            begin
              li.ImageIndex := 1;
              li.Caption := IdMsgSend.MessageParts.Items[idx].ContentType;
            end;
      end;
end;

> What are you talking about?  Attachments are always part of the MessageParts
> collection.

I get it now. In the email, message parts was not MessageParts and being
unfamiliar with the TIdAttachment properties I missed that.>

Any back to the main question, How do I make sure the Attachments are as files
not in the text of the message?

Thanks,

Chuck

Replies

In response to

Re: File Attachment in Indy 10 Mail Client demo is not working posted by Remy Lebeau (TeamB) on Fri, 11 Mar 2005