I'm trying to port data from an old format where I stored downloaded emails in
a decoded form into a new one where I'll hold just the mail as received.
I'm having major difficulty. I cut and pasted the code from the "new" app to do
the encoding, essentially changed a few field names to make things work. Its
fine unless there are embedded images in the email. These are coming through as
attachments. I've attached the structure for one that does work, and one that
doesn't below along with the code I'm using for conversion. Any and all
suggestions welcome after 2 days of banging my head.
Roy Lambert
DOES WORK
Content-type: Multipart/mixed; boundary="00747F19_62CC1397_Synapse_boundary"
Content-Description: Multipart message
--00747F19_62CC1397_Synapse_boundary
Content-type: text/html; charset=UTF-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline
Content-Description: HTML text
--00747F19_62CC1397_Synapse_boundary
Content-type: image/BMP; name="folders.bmp"
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; FileName="folders.bmp"
Content-Description: Attached file: folders.bmp
--00747F19_62CC1397_Synapse_boundary
Content-type: Multipart/related;
boundary="00747F28_231033BF_Synapse_boundary"
Content-Description: Multipart message
--00747F28_231033BF_Synapse_boundary
Content-type: image/BMP; name="cabinet.bmp"
Content-Transfer-Encoding: Base64
Content-ID: {919E0CCA-9D07-4DEB-9883-89FA835F9EF1}
Content-Disposition: inline; FileName="cabinet.bmp"
Content-Description: Included file: cabinet.bmp
--00747F28_231033BF_Synapse_boundary
Content-type: image/BMP; name="cabinet2.bmp"
Content-Transfer-Encoding: Base64
Content-ID: {B478ADD5-361B-4BBC-99E2-8BB5E9954D1D}
Content-Disposition: inline; FileName="cabinet2.bmp"
Content-Description: Included file: cabinet2.bmp
--00747F28_231033BF_Synapse_boundary--
--00747F19_62CC1397_Synapse_boundary--
DOES NOT WORK
Content-type: Multipart/mixed; boundary="006A6FF5_064429C2_Synapse_boundary"
Content-Description: Multipart message
--006A6FF5_064429C2_Synapse_boundary
Content-type: text/html; charset=UTF-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline
Content-Description: HTML text
--006A6FF5_064429C2_Synapse_boundary
Content-type: application/MSWord;
name="Client information for emailing- BHL Search and Selection lr Dec
02.doc"
Content-Transfer-Encoding: Base64
Content-Disposition: attachment;
FileName="Client information for emailing- BHL Search and Selection lr Dec
02.doc"
Content-Description: Attached file: Client information for emailing- BHL
Search and Selection lr Dec 02.doc
--006A6FF5_064429C2_Synapse_boundary
Content-type: application/MSWord; name="Mailshot jd June03.doc"
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; FileName="Mailshot jd June03.doc"
Content-Description: Attached file: Mailshot jd June03.doc
--006A6FF5_064429C2_Synapse_boundary
Content-type: application/MSWord; name="Mailshot lr Mar 03.doc"
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; FileName="Mailshot lr Mar 03.doc"
Content-Description: Attached file: Mailshot lr Mar 03.doc
--006A6FF5_064429C2_Synapse_boundary
Content-type: Multipart/related;
boundary="006A7014_02C82810_Synapse_boundary"
Content-Description: Multipart message
--006A7014_02C82810_Synapse_boundary
Content-type: image/GIF; name="dwvl0.gif"
Content-Transfer-Encoding: Base64
Content-ID: dwvl-0
Content-Disposition: inline; FileName="dwvl0.gif"
Content-Description: Included file: dwvl0.gif
--006A7014_02C82810_Synapse_boundary
Content-type: image/GIF; name="dwvl1.gif"
Content-Transfer-Encoding: Base64
Content-ID: dwvl-1
Content-Disposition: inline; FileName="dwvl1.gif"
Content-Description: Included file: dwvl1.gif
--006A7014_02C82810_Synapse_boundary
Content-type: image/GIF; name="dwvl2.gif"
Content-Transfer-Encoding: Base64
Content-ID: dwvl-2
Content-Disposition: inline; FileName="dwvl2.gif"
Content-Description: Included file: dwvl2.gif
--006A7014_02C82810_Synapse_boundary--
--006A6FF5_064429C2_Synapse_boundary--
CODE USED
function TForm1.EncodeEMail(eMail: TDBISAMTable): boolean;
var
Encoded: TMimeMess;
sl: TStringList;
MimePart: TMimePart;
Pics: TMimePart;
ms: TMemoryStream;
procedure AddAttachments;
begin
if not eMail.FieldByName('_Attachments').IsNull then begin
StreamMemoToTable('_Attachments', eMail, eAtts);
eAtts.First;
while not eAtts.Eof do begin
ms := TMemoryStream.Create;
TMemoField(eAtts.FieldByName('_Item')).SaveToStream(ms);
Encoded.AddPartBinary(ms, ExtractFileName(eAtts.FieldByName('_Name').AsString),
MimePart);
ms.Free;
eAtts.Next;
end;
end;
end;
procedure AddImages;
begin
if not eMail.FieldByName('_InLine').IsNull then begin
Pics := Encoded.AddPartMultipart('related', MimePart);
StreamMemoToTable('_InLine', eMail, ePics);
ePics.First;
while not ePics.Eof do begin
ms := TMemoryStream.Create;
TMemoField(ePics.FieldByName('_Item')).SaveToStream(ms);
Encoded.AddPartHTMLBinary(ms,
ExtractFileName(ePics.FieldByName('_Name').AsString),
ePics.FieldByName('_CID').AsString, Pics);
ms.Free;
ePics.Next;
end;
end;
end;
begin
sl := TStringList.Create;
Encoded := TMimemess.Create;
sl.Assign(eMail.FieldByName('_Headers'));
Encoded.Header.DecodeHeaders(sl);
sl.Text := StripToReadable(eMail.FieldByName('_Message').AsString);
MimePart := Encoded.AddPartMultipart('mixed', nil);
Encoded.AddPartHTML(sl, MimePart);
AddAttachments;
AddImages;
Encoded.EncodeMessage;
eMail.FieldByName('_Encoded').Assign(Encoded.Lines);
Encoded.Free;
// end;
sl.Free;
eMail.FieldByName('_Size').AsInteger :=
Length(eMail.FieldByName('_Encoded').AsString);
end;
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public