Synapse class implementing a mime-formatted message. Commonly used to encode/decode email messages. TMimeMess contains one or more TMimeParts. TMimeMess provides support for assembling, encoding/decoding and modifying mime messages. TMimemess contains one root TMimePart class, what can hold any subsequent tree of next tMimepart classes called as SubParts.
For access to subpart (subpart is nested MimePart) are methods:
This functions allows easy access to any part in message.
example:
You have tmimepart object called 'm', where is decomposed message. You need get headers of first subpart, whitch is second subpart of root multipart. For this you can use:
m.getsubpart(1).getsubpart(0).Headers
Example for create mail message with attached file:
procedure TForm1.Button13Click(Sender: TObject); var m:TMimemess; l:tstringlist; p: TMimepart; begin m:=TMimemess.create; l:=tstringlist.create; try p := m.AddPartMultipart('mixed', nil); l.loadfromfile('c:\search.log'); m.AddPartText(l,p); m.AddPartBinaryFromFile('c:\search.log',p); m.header.from:='youraddress@somewhere.com'; m.header.tolist.add('You@somewhere.com'); m.header.subject:='test message'; m.EncodeMessage; memo1.lines.assign(m.lines); //if you wish to send it by SMTP too, then: SendToRaw('youraddress@somewhere.com', 'You@somewhere.com', 'your.smtp.server.com', m.lines, 'yourusername', 'yourpassword'); finally m.free; l.free; end; end;
See MailAttach demo for another example.
Related subjects: TMimePart TSMTPSend TMimeMess