Andre Schnoor wrote:
> Is there a simple example available of how to assemble a multi-part
> email message (Net.MailMessage) that can deliver HTML and plain text
> side by side (e.g. for a newsletter)? I can't seem to figure that out
> from the huge API alone.
>
> Thanks in advance.
> Andre
>
>
Hi Andre,
the following works for us. It took me some time to get it right, but it
works for us.
You'll have to provide the details for the smtpclient yourself.
Regards,
Cham
sendEmailTo: recipiant subject: subject text: text html: html sender: sender
| msg ws partMsg relMsg |
msg := Net.MailMessage new.
msg subject: subject.
msg from: sender.
msg to: recipiant.
msg date: Timestamp now.
relMsg := Net.MimeEntity new contentType: 'multipart/alternative'.
partMsg := Net.MimeEntity newTextPlain.
partMsg contents: text.
relMsg addPart: partMsg.
partMsg := Net.MimeEntity newTextHTML.
partMsg contents: html.
relMsg addPart: partMsg.
msg addPart: relMsg.
((Net.SimpleSMTPClient new)
hostName: 'mail.somewhere.com';
username: '
[hidden email]';
yourself) sendMessage: msg.