How do I get HTML rendered in creating email message with velocity? - html

I use velocity to create a string writer, then merge that into a template. The template #includes html to make a simple table, yet only the raw HTML shows up in the email... it does not get rendered. Email is being sent from Google server to outlook client.
Can anyone tell me How can I get rendered HTML into an email message created with Velocity?
Thanks!

You have to set a Content-type: text/html header.
Appart from that, you have to be aware that all the different email clients may strip the HTML tags and features (for example, styles), so you have to experiment with different email clients and try to stick to a very basic feature set.

Related

HTML table in reply mail

We require the users to reply in a specific format about their problems. Our current application sends an auto-generated mail which has a mailto embedded like this
Contact Application Team
What we want now is to include a table in the embedded "mailto" so that user can describe their problems in much better way. We have tried encoding html inside mailto body, but it gets treated as simple text.
Is there any way to include the table in the mailto body or any better way to improve the interaction.
It is not possible to include HTML in the mailto body, as defined in Section 2 of RFC 2368.
Possible alternate solutions:
Have users type their information into an HTML form and then use PHP (or similar server side language) to send the email
Try to format your email a little bit nicer by adding in some line breaks. You can use %0D (Carriage Return) followed by %0A (Line Feed). Maybe something like this:
Contact Application Team

How tell Outlook where image files are?

Please bear with me; there's a long story coming up. It's about programatically creating HTML e-mails from Delphi-7, sending them to Outlook, and not showing the pictures in it, so if you don't know anything about that, don't bother reading it all.
I have an application that sends variable-text E-mails, from a Delphi-7 program, to Outlook. I'm using a TMailInfo item, use a template HTML file for layout, replace placeholders with data from the program (%NAME% becomes "Johnson" etc), create a new Outlook message and populate HTMLbody with my result. All of this works fine.
Recently my client sent me a new sample message, asking me if I could change this E-mail to the new layout as he sent me. So I saved the E-mail as html (from Outlook, generating a huge HTML file full of code that is hardly understandable for a non-HTML guru like me)), replaced the static data with my placeholders, and saved it as the new template.
This worked fine except for one thing - the new layout included some local pictures (not available from a public web resource). When original sample mail from outlook, two things were created - a htm file with the html code, named "Subject" AND a folder called "Subject_files", containing the picture files plus a filelist.xml and an mso file.
The generated HTML refers to the pictures as src="subject_files/image001.jpg"> etc.
When I send the HTML to Outlook, it obviously has no idea where the images are - but how do I tell him?
What I tried:
copying the "subject_files" folder to "My Documents"
hardcoding the links to the pictures in several formats (i.e.
src="C:/test/subject_files/image001.jpg",
src="C://test/subject_files/image001.jpg",
src="C:\test\subject_files\image001.jpg",
and the like
but both don't work... so my question is really, how do I tell Outlook where to look for image files when programatically creating an HTML message?
Thanks in advance!
Once you the email, the recipient does not have access to your computer, So the images won't show in the email. to send images in an email you can:
Use aboslute links
<img src="http://www.example.com/images/header.jpg">
Use embedded images
Convert your images to BASE64, you can find many web sites online to that like
https://www.base64-image.de/ then
<img src="data:image/jpg;base64,/*base64-generated-string*/" />
As mentioned by Remy, the images can be added as regular attachments. You will then need to set the PR_ATTACH_CONTENT_ID property (DASL name http://schemas.microsoft.com/mapi/proptag/0x3712001F) using Attachment.PropertyAccessor.SetProperty. The HTML body must use the matching value for the cid attribute - <img src="cid:xyz">, where "xyz" is the value of the PR_ATTACH_CONTENT_ID property.

Accessing attachments in html email?

I'm trying to send a HTML email and it works perfectly fine even the css, but I'm trying to use #font face. If I would be making a normal website I would just have it in a folder on the server. But since there is nothing like that while sending an html email I was wondering whether I could send the font as an attachment and have the html access it. The only thing is that I don't know what the url of email attachments is.
Thanks,
In order to refer to an attachment part from other parts of the message, you need to add a unique Content-ID header field to the attachment—for example, based on a hash sum of the font file (replace example.com with your own domain):
Content-ID: <font-d404d13b4009ec52325bafd11e8fa5c2#example.com>
Then, use a cid: scheme URL to refer to this attachment:
cid:font-d404d13b4009ec52325bafd11e8fa5c2#example.com
This works for images; I highly doubt that it will work for fonts, but you can try.

Sending HTML emails out from Plone

Are there examples of sending simple HTML formatted emails (<h1>, <b> and such) out from Plone?
Plain text is well-covered, but there are no HTML email out examples.
You can adapt any of the many python email module examples. Because HTML email usually means sending multipart/alternative messages, things get a little more complicated.
The examples page of the email package.
Sending HTML email using Python
Sending Multipart html emails which contain embedded images
You basically have to construct an email.Message object and pass that to Mailhost.send.
Depending on your use case, you could also use collective.watcherlist.
This was factored out of Products.Poi, which uses it to allow users to subscribe to updates for an issue. That part may not be interesting for you, but it has code that takes a browserview as basis for sending an email. Hooking a page template up to that browserview is of course simple.
If you cannot use it directly, it may serve as a code example.

html newsletter email arriving as an attachment

I'm using C# to send email newsletters for subscribers.
There's no problem with sending the email but some email clients like outlook and hotmail receive html newsletter as an attachment and the email body contains only plaintext with html tags removed and some clients like gmail receive the email just fine.
What actually creates this behavior? If i put just few html tags in to message outlook and hotmail shows the newsletter fine but as i put in more html elements my mail arrives as attachment.
I've been trying to find out how to make my email appear ok in most popular email clients like outlook but have had no success so far. Anyone care to enlighten me how this email + html stuff actually works?
Have a look at the Mailchimp and CampaignMonitor links in this answer, which may help you.
Since you don't provide any information about how you're using C# to send this email, we can only speculate about what you're doing and what the problem might be. It sounds like you might be using MailMessage.AlternateViews to send your HTML, but only have that one view. If you're not intending to send out a multipart/alternative message then you should simply set the MailMessage.Body to your HTML content with MailMessage.IsBodyHtml = true.
That being said: I make the assumptions I do because some email clients are smarter than others, and if the content-type header doesn't make sense they'll do their best to try to figure out what the nicest way to display the content is, each potentially trying something different. If, however, my assumptions are incorrect it would greatly help to know the code you're using to generate the email, and even an example of the message headers.