Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Jun : how to copy IdMessage.MessageParts (ver 9.018) ?

www.cryer.info
Managed Newsgroup Archive

how to copy IdMessage.MessageParts (ver 9.018) ?

Subject:how to copy IdMessage.MessageParts (ver 9.018) ?
Posted by:"Sean Hwa" (seanh..@hotmail.com)
Date:Sat, 11 Jun 2005 22:23:59

Hi,

I want to copy  IdMessageA.MessageParts to IdMessageB.MessageParts
But , MessageParts is a readonly collection

My current program as following  , can I get a correct method ?

procedure CloneIdMessage(Source: TIdMessage);
var i : integer;
  LTheAttachment : TIdAttachment;
begin
  if Source is TIdMessage then
  with FMessage do begin
    AttachmentEncoding := TIdMessage(source).AttachmentEncoding;
    Body := TIdMessage(source).Body;
    BccList := TIdMessage(source).BccList;
    CharSet := TIdMessage(source).CharSet;
    CCList := TIdMessage(source).CCList;
    ContentType := TIdMessage(source).ContentType;
    ContentTransferEncoding := TIdMessage(source).ContentTransferEncoding;
    ContentDisposition := TIdMessage(source).ContentDisposition;
    Date := TIdMessage(source).Date;
    DeleteTempFiles := TIdMessage(source).DeleteTempFiles;
    Encoding := TIdMessage(source).Encoding;
    ExtraHeaders := TIdMessage(source).ExtraHeaders;
    From := TIdMessage(source).From;
    NewsGroups := TIdMessage(source).NewsGroups;
    NoEncode := TIdMessage(source).NoEncode;
    NoDecode := TIdMessage(source).NoDecode;
    Organization := TIdMessage(source).Organization;
    Priority := TIdMessage(source).Priority;
    ReceiptRecipient := TIdMessage(source).ReceiptRecipient;
    Recipients := TIdMessage(source).Recipients;
    References := TIdMessage(source).References;
    ReplyTo := TIdMessage(source).ReplyTo;
    Subject := TIdMessage(source).Subject;
    Sender := TIdMessage(source).Sender;
    UseNowForDate := TIdMessage(source).UseNowForDate;

    //  copy MessageParts **************************************
    for i := 0 to pred(TIdMessage(source).MessageParts.Count ) do
      if (TIdMessage(source).MessageParts.Items[I] is TIdAttachment) then
begin
      LTheAttachment :=
TIDAttachment.Create(MessageParts,TIdAttachment(TIdMessage(source).MessagePa
rts.Items[I]).FileName );
      LTheAttachment.FileName  :=
TIdAttachment(TIdMessage(source).MessageParts.Items[I]).FileName;
      LTheAttachment.ContentTransfer
:=TIdAttachment(TIdMessage(source).MessageParts.Items[I]).ContentTransfer;
      LTheAttachment.ContentType
:=TIdAttachment(TIdMessage(source).MessageParts.Items[I]).ContentType;
      end;
    //********************************************************
  end ;
end;

Replies:

www.cryer.info
Managed Newsgroup Archive