Is there a way to format the content of an email in SMTPClient.jl
with HTML tags or in another way?
For example by using this example but with additional <b>
tags
body = IOBuffer(
"Date: Fri, 18 Oct 2013 21:44:29 +0100\r\n" *
"From: You <you@gmail.com>\r\n" *
"To: me@test.com\r\n" *
"Subject: Julia Test\r\n" *
"\r\n" *
"Test Message: <b>Important </b>\r\n")
Not sure what you mean by additional B tags, there is one in that message, it might work, it might not, you can add more and they might work or might not. I really depends on the client. Email is just text. It’s up to the client to decide how to display that text.
What mostly works is writing an actual HTML page in the body of the email, so if you did something like:
"""
<html>
<head>
[ Define CSS and whatever. ]
</head>
<body>
[ Enter the body of the message. ]
</body>
</html>
"""
One thing when writing HTML for email clients, you need to write it like it’s the 90s and use tables to do all your layout. Some email readers have never gotten with the times and fully embraced CSS.
You best bet is googling for “HTML email templates” and start with one of those and edit it for yourself.
2 Likes
Thank you!! With your help and looking for HTML email templates it worked.
I had to add "\r\n"
add the end of each element to obtain the working example
body = "Subject: A simple test\r\n"*
"Mime-Version: 1.0;\r\n"*
"Content-Type: text/html;\r\n"*
"Content-Transfer-Encoding: 7bit;\r\n"*
"\r\n"*
"""<html>
<body>
<h2>An important link to look at!</h2>
Here's an <a href="https://github.com/aviks/SMTPClient.jl">important link</a>
</body>
</html>\r\n"""
Btw: With additional b-tag, I meant that in SMTPClient.jl
there is no example that has HTML tags, e.g. a b-tag and I wanted to make this work.