Smalltalk Pharo ZdcSecureSMTPClient doesn't show html formatting in GMail?

I am using ZdcSecureSMTPClient to send html-formatted string to gmail account. But when I send it, it displays the html encoding as plain text. those.)

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 Gmail: "html> head> Dear / b> / head> / html> '

Use the Seaside / Pharo 2.0 image with one click.

+4
source share
2 answers

What you use to set the mime type is not as expected (in addition, the content of the message should be in body, not head). Use something like the following:

mailMessage := MailMessage empty.
mailMessage setField: 'subject' toString: 'Trying to send html '.
mailMessage addMixedPart: '<html><head></head><body><i>  Dear</i>   </body></html>' contentType: ZnMimeType textHtml printString.

ZdcSecureSMTPClient sendUsingGMailAccount: 'you@gmail.com' password: 'XXXXXXX' to: 'recipient@server.com' message: mailMessage.

, text message.

+3

. , :

mailMessage: = MailMessage .   mailMessage setField: 'from' toString: from.   mailMessage setField: 'to' toString: to.   mailMessage setField: 'subject' toString: subject.   mailMessage addAlternativePart: textBody content contentType: 'text/plain'.   mailMessage addAlternativePart: html contentType: 'text/html'.

: http://forum.world.st/Re-Seaside-dev-Accessing-service-from-a-mail-td4671547.html#a4672088

0

All Articles