Retrieving pop3 mail messages to a database

clPop3.UserName := 'user';   
clPop3.Password := 'psw';   
clPop3.Open();   
clPop3.Retrieve(MsgNo);   
 
if not (DataSet1.State in [dsInsert, dsEdit]) then   
   DataSet1.Insert();   
stream := TMemoryStream.Create();   
try   
   clPop3.Response.SaveToStream(stream);   
   BlobField1.LoadFromStream(stream);   
finally   
   stream.Free();   
end;   
 
DataSet1.Post();
 
clPop3.UserName := 'user';   
clPop3.Password := 'psw';   
clPop3.Open();   
clPop3.Retrieve(MsgNo, clMailMessage1);   
 
if not (DataSet1.State in [dsInsert, dsEdit]) then   
   DataSet1.Insert();   
 
DataSet1.FieldByName('message_id').AsString := clMailMessage1.MessageID;   
DataSet1.FieldByName('message_from').AsString := clMailMessage1.From.FullAddress;   
DataSet1.FieldByName('message_subject').AsString := clMailMessage1.Subject;   
DataSet1.FieldByName('message_date').AsDateTime := clMailMessage1.Date;   
DataSet1.FieldByName('message_text').AsString := clMailMessage1.MessageText.Text; 
 
DataSet1.Post();

Add Feedback