I'm using ZdcSecureSMTPClient to send an html formatted string to a gmail account. But when I send it it displays the html encoding as plain text. ie)
mailMessage := MailMessage empty.
mailMessage setField: 'subject' toString: 'Trying to send html '.
mailMessage body: (MIMEDocument contentType: 'text/html\n'
content: '<html><head><b> Dear </b></head></html>'
This shows is Gmail as: 'html> head> Dear /b>/head>/html>'
Using Seaside/Pharo 2.0 one click image.
Thanks everyone for the swift and quick answers. I found the solution to be adding the alternative part the message as below:
mailMessage := MailMessage empty. mailMessage setField: 'from' toString: from. mailMessage setField: 'to' toString: to. mailMessage setField: 'subject' toString: subject. mailMessage addAlternativePart: textBody contents contentType: 'text/plain'. mailMessage addAlternativePart: htmlBody contents contentType: 'text/html'.
the link is: http://forum.world.st/Re-Seaside-dev-Accessing-service-from-a-mail-td4671547.html#a4672088
What you use to set the mime type is not what is expected (additionally, the content of the message should be in
body
, nothead
). Use something like the following:You can check that your message is correct by sending the message
text
to yourmessage
object.