pop3 relayed to exchange smtp mailbox

Giganews Newsgroups
Subject: pop3 relayed to exchange smtp mailbox
Posted by:  Marc Tessier (tessier.ma…@videotron.ca)
Date: Wed, 7 Jun 2006

I have coded a idpop3 to retrieve mail from a pop3 account and relay them to
a exchange smtp account using tidsmtp.

The pop3 messages are relayed to the smtp without problem but the
attachments are corrupted. In my test I was receiving .WAV file that are
attached to the email in base64.  Since I am not touching the message
except  for the TO, CC and BCC.  I can only explain my corruption because of
the tidpop3 or tidmessage components that are corrupting it.  I tried the
ReceiveRaw (into a text file) and loaded it (from that file) into a
tidmessage and the attachments are still corrupted.  If I use another
utility like poproute, the attachments are ok).

here my code:
====================================
// components dropped on a form
idpop3 : tidpop3
s1 : tidsmtp;

var
  mess : tidmessage;
  msgnum, msgcount : integer;
Begin

try
    if not idpop31.Connected then
    idpop31.Connect
  except
    showmessage('Could not connect to pop server, please check your
connection details');
    exit;
  end;

  try
    if not s1.Connected then
      s1.Connect
  except
    showmessage('Could not connect to smtp server, please check your
connection details');
    exit;
  end;

  msgnum:=0;
  msgcount:=0;

  msgcount:=idpop31.CheckMessages;

  if  msgcount > 0 then
  for msgnum := 1 to msgcount do
  begin
    mess.Clear;

    idpop31.Retrieve(msgnum,mess);

  // Added to header to keep original information
  mess.headers.add('TO: '+mess.Recipients.EMailAddresses);
  mess.headers.add('CC: '+mess.CCList.EMailAddresses);
  mess.headers.add('BCC: '+mess.BCCList.EMailAddresses);

  // Clearing To:, CC, and BCC and adding destination email to receive all
pop mail. clearing it to
  // avoid using the old lists as destination for the email
  //
  mess.Recipients.Clear;
  mess.CCList.Clear;
  mess.BccList.Clear;
  mess.BccList.Add.Address := 'monit…@domain.local';

  // Sending the message received from pop.
  s1.Send(mess);

  end;
s1.Disconnect;
idpop31.Disconnect;

end;

Replies