so i take it, from the dearth of replies, that no one on this list uses synapse or its mime library?
i've reduced/stripped the code to produce the attached .pas file... while i now do not get a line number any more (which i also do not understand), at least i can more easily see now that the problem is associated with freeing the second (last??) instance of the created m1 var... i'm working with an email message that is multipart with a text/plain part first and a text/html part second... i don't currently have a three part multipart message to work with and for this application, it is doubtful that one will appear but it would be best to code for the possibility i think... my goal is to extract only the text/plain portion and decode any mime'd characters to CP850 ascii equivalents... no, not 7-bit but 8-bit if necessary... an example is decoding = 9 9 (that's equal nine nine without the spaces) to "(tm)" (that's open parens, Tee, Emm, close parens)...
can anyone assist with the reason for the exception?? i'm using the last release code of synapse (download zip archive) with FPC 2.4.3... currently on win32...
here's the screen output for the attached code... C:\freepascal\projects\arnews>tstmime1 arnews4.req entering ProcessParts... allocate m1 for part 1 assign m1.OnWalkPart for part 1 pulling part 1 into m1-1 ** WE HAVE A TEXT/PLAIN SECTION ** finally free m1 for part 1... m1 <> NIL... Destroying... done! done! allocate m1 for part 2 assign m1.OnWalkPart for part 2 pulling part 2 into m1-2 This part is not TEXT/PLAIN... DELETING... firing m.DeleteSubPart(1 back from m.DeleteSubPart... Done! finally free m1 for part 2... m1 <> NIL... Destroying... An unhandled exception occurred at $6275736E : EAccessViolation : Access violation $6275736E
{$MODE DELPHI} Program testmime; uses mimepart, synachar, classes; type Tc = class(TObject) public class procedure ph(const Sender: TMimePart); end; class procedure Tc.ph(const Sender: TMimePart); begin Sender.DecodePart; Sender.EncodePart; end; var m: tmimepart; PartCount: integer; m1: tmimepart; MyPart: integer; MyPartCount: integer; begin m := tmimepart.create; // try m.OnWalkPart:=tc.ph; m.Lines.LoadFromFile(paramstr(1)); m.DecomposeParts; m.WalkPart; PartCount := m.GetSubPartCount; if m.Primary = 'MULTIPART' then begin writeln; writeln(' entering ProcessParts...'); for MyPart := 1 to PartCount do begin if MyPart > 1 then writeln; writeln(' allocate m1 for part ',MyPart); m1 := tmimepart.create; try writeln(' assign m1.OnWalkPart for part ',MyPart); m1.OnWalkPart:=tc.ph; writeln(' pulling part ',MyPart,' into m1-',MyPart); m1:= m.GetSubPart(MyPart - 1); if ((m1.Primary = 'TEXT') and (m1.Secondary = 'PLAIN')) then writeln(' ** WE HAVE A TEXT/PLAIN SECTION **') else begin writeln(' This part is not TEXT/PLAIN... DELETING... '); writeln(' firing m.DeleteSubPart(',MyPart-1); m.DeleteSubPart(MyPart - 1); writeln(' back from m.DeleteSubPart...'); writeln(' Done!'); end; finally writeln(' finally'); writeln(' free m1 for part ',MyPart,'... '); if m1 <> NIL then begin write(' m1 <> NIL... Destroying... '); m1.free; writeln('done!'); end else writeln(' m1 = NIL... no destroy necessary...'); writeln(' done!'); end; end; writeln(' vacating ProcessParts...'); end; writeln; writeln(' fire m.ComposeParts...'); m.ComposeParts; writeln(' return from m.ComposeParts...'); writeln(' fire m.Lines.SaveToFile...'); m.Lines.SaveToFile(paramstr(1) + '.repack'); writeln(' return from m.Lines.SaveTofile...'); // finally writeln; writeln('finally'); write(' free m... '); m.free; writeln('done!'); // end; writeln('Process complete. Terminating...'); end.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal