In my ColdFusion program I create email (HTML/CSS) for one or many recipients, and place it in a .cfm file. The email is nicely formatted. When I run the saved file as a program, the cfmail tag sends the email along to whomever, and that is all working. However, along the way, my formatting gets lost. I understand that there is no reason for my local CSS to be functioning when the email gets to its target. But it would be nice if I could preserve the formatting I started with.
Does anyone have a suggestion about how I might do this.
If you're not including the attribute type="html" in your cfmail tag, that could be affecting the formatting of your email. Also, within the cfmail tag, embed your style within in addition to your content. For example:
<cfmail from="foo#bar.com" to="foobar#bar.com" subject"test" server="mymailserver" type="html">
<html>
<head>
<style>
.test { color: ##cc0000; }
</style>
</head>
<body>
<div class="test">This email is in red</div>
</body>
</html>
</cfmail>
Styling emails can be tricky as it's different across clients - there are whole blog articles devoted to this. For example, styles in the head section get ignored in some clients and recognised in others. Sadly, inline styles seems to be the "best" approach.
There is a good overview on the campaign monitor website of what works if which clients:
https://www.campaignmonitor.com/css/
Mailchimp have a handy tool which will inline styles for you based on your HTML/CSS:
http://templates.mailchimp.com/resources/inline-css/
It's also worth including a plain text version for maximum compatibility. You can do that like this:
<cfmail to="someone#somewhere.xyz"
from="me#here.xyz"
subject="Hello!"
type="html">
<cfmailpart type="text/plain" wraptext="60">
Hello,
This is plain text version
</cfmailpart>
<cfmailpart type="text/html">
<h3>Hello</h3>
<p>This is <b style="color:red;">HTML</b> version</p>
</cfmailpart>
</cfmail>
Related
I am trying to display an image in powershell email body
tried below
$body = #"
Hi Team,
Please find the attached report
Note: To view the Index page, please click on Enable editing option in excel
<html>
<body style="font-family:calibri">
<img src='cid:enable_editing.png'>
</body>
</html>
Thank you
***This is an auto-generated email. Please do not respond***
"#
There are 2 excel attachment which goes with the email.
Please let me know how to display that
When I am sending the image as attachment and making -BodyAsHTML, I am loosing the email formatting
Naturally with -BodyAsHTML your text would need to be part of the HTML and naturally you'd need to use HTML linebreaks to well ... have linebreaks. Your whole body needs to be HTML.
So for example you'd have something like:
<html><body>
<p>Hi Team,</p>
<p>Please find the attached report. <br/> To view it to X.</p>
<img ... />
</body></html>
Beware that HTML formating is usually limited within mail clients. Not every tag and CSS format will work.
I am having an issue with emails being sent to users from a saved template. In this template there are non-breaking spaces to preserve formatting that is expected, and there is no issue forming the link or sending the email.
However it seems that after going through the mail server when the tags are displayed on their preferred mail service, some users are seeing the hypertext link malformed.
Example,
This is how the raw link looks in the message we send,
Log in to <a href=\"https://website"\>https://website</a> to
And this is how users are reporting they are seeing the link in the message,
https://website to
Instead of,
https://website
I was able to pull the raw message from a test email after sending it to myself and didn't see that there was any issue with the encoding. Has anyone dealt with this before?
I am not sure if it may be better to try and strip out the character and replace it with a regular space? Or if there is another way to handle this?
You could try wrapping the link with a <span> and it might solve the problem... Note that I have replaced the escaped double quote \" with a single quote '
<!DOCTYPE html>
<html>
<body>
<label>Wrapped the link with a span</label>
<div>
Log in to <span><a href='https://website'>https://website</a></span> to
</div>
</body>
</html>
I'm creating a simple email client and I'm having trouble with Reply and Forward in html emails.
When I have the user compose the reply message, how do I append that content to the top of the message? I have done some investigating with how outlook does it by injecting the new message content into a paragraph or div or something like that.
How is it done in general, i.e. gmail, yahoo, etc. How do they figure out where to inject the reply content in the html?
I'm using c# so ideally there is some c# library that can handle this? If not then some idea how it's done generally so I can create a solution for it.
I've read wikipedia's Posting Style article and it gives a good overview of the general idea but nothing about how to do it in html.
Some Background
When composing HTML email, it is important to recognize that email clients have rather limited support for HTML and the level of support varies across email clients.
Because of that, although <div> and CSS are the correct layout tools for web pages, that is not true for HTML email. Even today, use <table> for layout control for HTML emails.
Additionally, the only reliable means to apply CSS is to the HTML elements with a style= attribute on each element. CSS declarations in a <head> section are often ignored by the email client. When crafting HTML email, I actually use CSS in the <head> and, once it looks correct, use this page to convert the HTML to use style= attributes. There are other options.
Not only will the <head> tag often be ignored, but so will any <body> tag.
Solving Your Problem
I would suggest placing the text included in the reply within a table (with a single <tr> and single <td>), and applying an inline CSS style to that table. That allows you to apply formatting, such as placing a colored bar down the left-hand side, italicizing the text, etc.).
When sending an HTML e-mail, is there any sense in using the <title> tag? In the PHP Manual, for instance, they use such a tag in their main sample code. However, I see no reason why an e-mail client would use this title and not the Subject from the e-mail. Is there any reason to set this tag?
I've been looking into this myself as I'm writing a PHP mailing list manager script that uses the sendmail() function.
The script allows the admin to create and send multiform emails (both text and html versions).
After much testing I have found that some email servers appear to have issues with the title tag (<title></title>).
I created a test email and sent it to 5 of my email address, my #blueyonder.co.uk email failed to arrive but the 4 others had no problems.
After a process of elimination it turned out that the #blueyonder.co.uk mail servers did not like the title tags in the html part of the email message, when I removed the tag the email arrived no probs.
Very strange!
The only use I would see is that some clients, like Outlook, allow you to view an email in a browser for better rendering. It would then be a plus to have the html title tag set.
(Old question, I know ;) )
My experience is that some mail clients will display the <title> tag in their email preview and some won't. Some clients preview will be "Subject + <title> + Preheader" and some will only be "Subject + preheader", so that creates an inconsistent experience.
Because of that, I found it's better to only use a preheader.
For completion's sake, the "Preheader" is a hidden text form the body that is only used in the preview, for example, something like...
<div style="display: none; max-height: 0px; overflow: hidden;">
Insert hidden preheader text here
</div>
Emails sent with html are obviously able to easily contain hyperlinks to web resources. What I want to understand is how best to include those links in a plaintext portion of the email?
Does this have any affect on spam ?
For example, our IT management system sends out emails and occasionally we encounter a customer that is ending up with system messages in their spam.
The system handles tickets and notifies the user when they are updated or modified so they know to go back to the site to check the status of their ticket.
The HTML portion would like something like:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div>Short description: can't see web content hosted on phoenix</div><div>Assigned to: .... </div>
<div>Assignment Group: ...</div>
<div>Priority: 4 - Standard</div>
<div>Click here to view:
LINK-INC999999
</div>
<div>Ref:MSG951683</div>
</body>
</html>
And the plaintext portion would like something like:
Short description: can't see web content hosted on phoenix
Assigned to: ...
Assignment Group: ...
Priority: 4 - Standard
Click here to view: LINK-INC999999
Ref:MSG951683
In this plaintext portion what is most appropriate way to include the same hyperlink so a user can easily see this link whether they prefer email in plaintext or html ?
I don't know about the spam implications, but plain text does not have hyperlinks. Some email clients will render a link on any text that starts with a URI schema (http://, https://, mailto: etc...), however you can't rely on that.
If you want people viewing plaintext to be able to use the link, you should render it on a line on its own. Then they can copy/paste into a browser if they wish to.