Location of code when sending HTML Email - html

I'm trying to figure out where to put some code in an email. You know how you can get newsletters with styling and images, etc? I wanted to send some out but I cant figure out where to put the code. Do you add the images as attachments? Do you put the code in the body?
or should you upload the .html file as well?

Build the page as a normal HTML page. Use TABLES (yes, TABLES) for your layout. You can use inline CSS, but you cannot use a stylesheet. All images must be fully-qualified (http://yoursite.com/images/). Don't make it wider than about 650 pixels. No JavaScript.
View your newsletter HTML in a browser
Do a select-all, and copy
Paste it into a new message and send it to yourself
See what you end up with
Try other mail clients
Various mail clients will mess with your markup and your styles. What works on Gmail will look like poop on Outlook etc. It will be an exercise in frustration. Test, test, test.
Assume all images will NOT BE SHOWN when the user originally views the email.
Here's a good guide to what works and what doesn't:
http://www.campaignmonitor.com/css/
My advice: keep it simple - a logo and some text and a link to the real newsletter. Making email newsletters is a fine art, and frankly, people prefer to read them in a browser where they behave like a web page.

Sending out HTML emails eigh?
There can be a lot of problems you will quickly encounter, mostly revolving around each email client having their own different way of handling things. The aim here is to keep your email as small, simple, and unbroken as possible.
The message:
Each language has it's own requirements, you need to check with the language you are using to see what is easier, to do it inline as part of the mailing script, or to have it inserted through a HTML file, etc. So for more details here, post the language you're using.
Layout:
This is where message simplicity comes in. The best layouts are usually the most simple ones, especially considering not all email clients are 100% HTML standards compliant. You won't know how big your client's viewing window for the email will be nor can you force it to any size or pop it out. Remember that it's goal is to be a message, not a webpage. Usually simple flexible/elastic tables will do the trick just fine if you have anything more advanced than simple paragraphs.
Images:
Link everything statically (statically means http:\\www. ....mypicture.png as opposed to dynamic linking which looks like this \images\mypicture.png) hosted from your server. The reason for this is so that you will have no broken links, your email will be smaller in size (as opposed to attatching). The downside is that some clients may ask about showing pictures. The cold hard truth is that this cannot be avoided no matter which method you use (See for more details).
Links:
Again, link everything statically. Local/dynamic link's won't work and your recipients will be mighty unhappy.
CSS
Either have your CSS classes at the top, or everything in-line (< ... style="..." />). You don't want to attach a CSS file, it's messy and unconventional.
Scripts
Inline or at the top of your file, for the same reason as above.
Additional Documents
If you want to include PDF's or DOCX's, etc, the best and most common methodology is just like images, to host on your server and simply include a static link in your email to them. It keeps file size down and you don't have to worry about what each and every email browser/reader is going to do.

Related

Dynamically resizing HTML emails

I'm writing an HTML email which functions perfectly well in the browser. But I've just been sending it by copying what's in the browser window and pasting it into the mail app on my computer and sending it that way. This doesn't do a lot of the things I want it to like resizing with the window and staying centered in the page.
How do big companies send HTML emails? because the positioning always works in a lot of the emails I get from them.
First HTML emails rely on tables so make sure you are coding your email using a table structure and not coding it how you would a normal webpage. Second make sure all your CSS is inline. Third you can send your emails using email automation services like MailChimp, Marketo, Constant Contact, GetResponse, etc.
If you want to send yourself a test email you could use a service like PutsMail for free.
You might also try following this tutorial to help you with creating a responsive email template.
Rule 1: Code like it's 1999 and use tables.
Rule 2: On all tables, set "width:100%; max-width: 600px;margin:auto;". You can replace the max-width with any value you want. The first two properties will make sure that the email fits the width of mobile devices. The second property will keep it centered.
There are a lot more rules and exceptions to the rules, but these are some good basics to start with when it comes to responsive design.

How to send a newsletter?

I am a newbie and this it is the first time that I have created an html and css code.
I have written a newsletter and now I would like to send it but I do not have idea about how.
Right now the situation is as following:
I have a folder with an HTML file, a folder with the CSS file and another Folder with all the images.
Now I would like to send it, but as I said before I do not know how.
I have red that I need to make a unique file HTML and CSS (HTML with an in line CSS). Is that the only way to go?
Which program do you suggest to send the newsletter?
Where should I store the images in order to make them visible to the recipients?
Any suggestion???
Like everyone above me, I would recommend Mailchimp too.
Now why it would be ideal in your situation is 'cos:
Since you've already created a separate html and css file, merging it into inline styles is going to take considerable effort if you have a lot of content. Mailchimp has a wide variety of templates to choose from where you can just pick a template which suits you and add just the content part.
Newsletters are very tricky to code since all email clients display content in a different way unless you're really proficient at writing newsletter html files from scratch. For eg, the email client Outlook (Microsoft) will ignore margins and some other css properties. The templates from Mailchimp have been perfected to show your content exactly like your design across almost all major email clients.
If you're going to send out a big number of newsletters, your newsletters might go into spam folders based on a variety of reasons. Mailchimp has authentication so that unless you go against some obvious law, your newsletter will land in your recipient's inbox.
You can also host your images on your own server and ask Mailchimp to reference that location. I do this when I send out newsletter for my website.
Its even got free plans to help start you out and see if it works out for you.
Try Mailchimp it is faster, easier and gives more options.
There are many tools availbale which gives services for sending emails also many other features.
As your HTML mailer is ready with image folders. Try to use inline style and for the images use full path like http://company.com/image/name.jpg ofcourse you have to place this HTML file and image folder on the server as well. And then you have to copy all the HTML code and place in any marketing tool and then you ready to send emails.
Mailchimp
Pardot
Constant Contact
you can choose constant contact to sending email.they offer 30 days free trial.
MailChimp is a good bet. Their API is wide enough to get into customising the hell out of their standard templates. Watch their pricing though, it can get out of hand the larger your cliental gets!

Is BMP to CSS/HTML conversion possible

It is theoretically possible to have a converter, that scans the color areas of a bitmap image and creates the same looking image, but using the CSS/HTML. CSS could be controlling colours of pixel-small html blocks. The further optimisation could be done by introducing the larger html blocks with similar color maps.
The resulting markup would be very large, but is it theoretically possible to achieve?
The main goal is to be able to e-mail clients a good looking promotional and informational e-mails, bypassing the problem of 99% of the recipients won't click to enable images in an e-mail. With such HTML-encoded images, a sender is sure that the e-mail looks as expected on the client side.
CSS does not reliably render in email. Bypassing any problems with your theoretical scanner, this is why images are the go-to standard in designed emails.
To see what I mean, look at Campaign Monitor's Guide to CSS support in email.
This would generate so much markup and put such a strain on the rendering engine of the recipient's email client that I don't think it would be viable in practice.
Also I wouldn't trust most email clients to render CSS accurately / reliably.
It is probably theoretically viable (in terms of actually generating the HTMl/CSS), although screen size may be an issue with this (for example divs could get pushed onto the next line whereas in the image they were inline).

Rules when creating HTML E-Mails?

Is there anything I need to be aware of when creating a HTML e-mail? Is it as simple as creating a valid HTML page then sending it via PHP? Or do I need to use tables to ensure it display's correctly.
Any advice to get this right first time would be much appreciated.
Creating an HTML email that displays the way you want to in email clients, can be very difficult, if not impossible. Unfortunately, email clients do not use the latest and greatest web browsers when displaying emails, and they can also restrict what should be allowed (and with good reasons).
No matter how much you might love CSS-based layouts, table-based layout is still the way to go for HTML emails. You can still use CSS for other things, of course, but in some cases it will need to be inline. The best looking HTML emails I've seen, are largely made up of tables and big images - simply because unlike on normal web pages it is nigh on impossible to create the equivalent using good web development practices. HTML email is a world of its own.
You should also test the emails in as many email clients as you can - and while it can be cumbersome to install all the different clients, you can also use services such as Litmus, MailChimp and CampaignMonitor (see also this question). Personally I have had good experiences with Litmus.
Good luck, creating HTML emails can be quite messy!
Tables are definitely the best option for HTML emails, since most other methods tend to display differently on different machines.
Things to watch out for:
Images are often blocked by email programmes - try to use background colours where possible
Don't link to an external stylesheet - put the styles in <head>. This will prevent your server being hit when the emails are opened.
There's also a good blog post from Mailchimp about using CSS in HTML emails.
Tables is bad...but the correct way to go in emails...
Also send only the part you would normally put in the body and only use inline css.
Another important thing is that background images most of the time dont work.
This is a very good guide that can help you out.
my advice: test in a lot of browsers,mailclients and email programs
You should check out Email on Acid, they not only show you what your email will look like in each client they also analyze your HTML. They highlight the HTML in you code that is not supported in the clients. This tool has saved me hours trying to figure out why an email doesn't render correctly.
One other thing that is very helpful is they provide Tips & Tricks for each client. Anyway you might want to check it out, very helpful.

HTML email: tables or divs?

Does the HTML/CSS for an html email newsletter need to be in table format, or can I use DIVs with equal assurance it will display well cross email-client? I've downloaded a number of templates to see how they're done, upon which to base my own, and they all seem to use tables.
Any insight much appreciated, thanks!
⚠️ Update 2021-06-10: This is a very old answer. I'm not sure how accurate it is 10 years after it was written. Mail clients are hopefully more compliant today ⚠️
When it comes to email HTML, note that all best practices from web development goes out the window. To make the look consistent, you should:
Use table based layouts
Use the old-school attribute styling for tables
Use ONLY inline-styles, and only very simple such. <style>-tags are discarded by many clients.
Skip using <html>, <head> and <body> - They will be discarded by most clients anyway.
If you embed images, try to make sure that the e-mail looks decent even if images are not loaded. Many clients require the user to mark the email as "safe" before displaying images.
You can read more detailed versions of the above points here:
http://articles.sitepoint.com/article/code-html-email-newsletters
http://dennisdeacon.wordpress.com/2008/06/09/top-10-email-best-practices/
http://www.catswhocode.com/blog/best-practices-for-coding-html-emails
Like everyone here has said, use tables and inline all your css... but there is an ecosystem of email apps to help you build emails.
I've been using Mailrox (https://www.mailrox.com/) for most of my email builds recently and it seem to be pretty damm good and outputting perfect HTML emails, if you're building one from a design, even though it's in beta.
You could also try pre-built templates from Mailchimp or Campaign Monitor, but it sounds like you have a design for your email so maybe Mailrox would be best.
If you really want to get into building emails I'd say forget most of what you know about modern webdesign and master table layouts and use the links from PatrikAkerstrand.
Litmus is also great for testing your hand-coded designs. They give you previews of your email in (pretty much) all the email clients.
Hope this helps.
Many email-clients aren't able to render css. I would use tables to format your mail and use images for anything else.
As it's already been mentioned - your HTML emails should be built using tables (and not divs). You can add CSS as well - both using an external stylesheet, but this will not be picked up by all email clients, so it's actually more reliable to add your css in-line. Even when doing so, some attributes might be ignored by certain email clients, so your best bet is still using HTML attributes whenever these are available. "You must do this because the some clients, such as Gmail, will ignore or strip out your tag contents, or ignore them." Source: http://webdesign.tutsplus.com/articles/creating-a-simple-responsive-html-email--webdesign-12978
That aside, I've also learned through trial and error that even images must be cropped to the exact size you want them displayed in your email. Outlook if terrible at picking up HTML attributes for width / height for images, and i have seen a few nasty stretched emails, only because these attributes were ignored and the images was displayed full size.