I am using the ColdBox MailService plugin to send emails. I am not sure how to include/embed an image in my email.
I tried the <cfmailparm> tag but this will not work because it is not enclosed in a <cfmail> tag.
<img src="cid:headerImage" width="350" height="263" alt="" /><br />
<cfmailparam file="/#application.rootDirectory#/includes/img/generic_header_lg.gif"
contentid="headerImage"
disposition="inline"/>
Is there another option I can try with the MailService plugin?
The mail service has methods to add Params. Have you looked at the API
Extrapolating from the docs, try addMailParam(disposition='inline')
Example
local.Email.addMailParam(disposition="inline"
,file="/#application.rootDirectory#/includes/img/generic_header_lg.gif"
,contentid="headerImage");
Related
I've found that I can make a gif show up on the README.md page like so:
![gif](https://github.com/jss367/antools/blob/gh-pages-2.3.4/assets/images/cat.gif)
or like so:
<img src='https://github.com/jss367/antools/blob/gh-pages-2.3.4/assets/images/cat.gif' />
However, those same lines of code don't work when I add them to a blog post. Do I need to add something to the layout? Or is it turned off in Github Pages?
I've found that they show up on the blog post when the gif is hosted on gifs.com but not when hosted on Github. For example, this works:
<iframe src='//gifs.com/embed/k8A5jN' frameborder='0' scrolling='no' width='1280px' height='720px' style='-webkit-backface-visibility: hidden;-webkit-transform: scale(1);' ></iframe>
but this doesn't:
<iframe src='https://github.com/jss367/antools/blob/gh-pages-2.3.4/assets/images/cat.gif' frameborder='0' scrolling='no' width='1280px' height='720px' style='-webkit-backface-visibility: hidden;-webkit-transform: scale(1);' ></iframe>
I'd like to host it directly on github.com.
Your link goes to a webpage. Use a direct link or proper directory
Try this:
<img src='https://github.com/jss367/antools/blob/gh-pages-2.3.4/assets/images/cat.gif?raw=true' />
I've write a functionality about send email process. Here I've set Mail Server details admin setting. And write a below code for sending email. I can successfully send & receive email to my gmail account. But Here I've added some paragraph with anchor tag value that is click me.
<cfoutput>
<cfmail from="test#gmail.com" to="test#gmail.com" username="myemail#gmail.com" password="mypass" port="587" subject="Chaange title" >
<p> I'm from test link click Me 2! </p>
</cfmail>
</cfoutput>
The issue is in my email not received as a click me as a link. Instead it will display entire html about anchor tag. FYR please refer my email content image.
Note : I've already tried with cfsavecontent too but it's not help me.
Could you any one help on this. Why it's was happen ? Thanks in advance.
Add type="html" to your cfmail tag. That should indicate to the end user's email client that the message should be displayed as an HTML page instead of just plain text.
As part of an SEO enhancement project, I've been tasked with adding the following property inside the markup for the image that the field renderer is generating on the page:
itemprop="contentURL" - before the closing tag.
<sc:FieldRenderer ID='FieldRenderer_MainImage' Runat='server' FieldName='Homepage Image'
CssClass="_image" Parameters="w=150" itemprop="contentURL" />
When I tried to place this inside the Field Renderer, or add it as a "parameter" - it doesn't work.
Is there another way to do this, without having to create a control file and generate the output in the code-behind?
You need to use the "Parameters" property for setting extra properties on both the and control.
You can to it like this :
<sc:FieldRenderer ID="PageImage" runat="server" FieldName="ContentImage" Parameters="ControlType=C4Image&rel=relString" />
<sc:Image ID="SCPageImage" runat="server" Field="ContentImage" Parameters="ControlType=C4Image&rel=relString" />
That will be rendered like this :
<img width="1232" height="637" controltype="C4Image" rel="relString" alt="" src="~/media/Images/DEMO backgrounds/background2.ashx">
Note: This works in 6.5 and 6.6 - not sure which version is being used in this question.
Couldn't this be done by extending the RenderField pipeline? You could potentially decompile (using Reflector or ILSpy) the GetImageFieldValue and add your own logic to adjust the output from the ImageRenderer?
Reference Sitecore.Pipelines.RenderField.GetImageFieldValue.
In cases where "Parameters" doesn't work or trying to create a Custom control, and instead of wrapping the control in a classed div like this:
<div class="my-class">
<sc:FieldRenderer runat="server" />
</div>
You can use this:
<sc:FieldRenderer Before="<div class='my-class'>" After="</div>" runat="server" />
Notice the Single quotes in the class declaration of the div above.
This keeps it a little cleaner and in context with the Sitecore control instead of a Web Developer adding an external div that might later lose its context if changes occur.
I recommend saving yourself some trouble and using the MVC version of Sitecore though, now, (when starting new Sitecore projects), as you can very simply add a class to it like so:
How can I get Sitecore Field Renderer to use a css class for an image
You actually cannot do this on a FieldRenderer. You're options are:
Extend the FieldRenderer with the ability to do this (this will likely require a high level of effort)
Use a regular .NET control and bind the data from the Sitecore item via the C# code-behind.
You may want to try using the <sc:image /> tag.
If you add a custom parameter there, it's added as an attribute to the img tag.
In your case the tag will look like this:
<sc:image runat="server" field="Homepage Image" width="150" itemprop="contentURL" class="_image" />
using mvc, I found this was easier than extending the FieldRender, should be reusable, but will have to test a bit more. WIP.
var image = "<span class=\"rightImage\">" + FieldRenderer.Render(contentBlock, "Image", "mw=300") + "</span>";
var text = FieldRenderer.Render(contentBlock, "Text");
model.Text = FieldRendererHelper.InjectIntoRenderer(text, image, "<p>");
public static HtmlString InjectIntoRenderer(string parentField, string injectField, string injectTag)
{
return new HtmlString(parentField.Insert(parentField.IndexOf(injectTag, StringComparison.InvariantCulture) + injectTag.Length, injectField));
}
I'm wondering if someone could help me out there.
For Java project I want to use the Jetty HttpClient that will send data to a Restful webservice.
Have a few questions:
Does Jetty client support multipart/form-data post?
From Jetty doc, to send any data you need to specify the request content by using HttpExchange.setRequestContent(Buffer) Or HttpExchangge.setRequestContentSource(InputStream) method. If I go with setRequestContentSource for file uploading how could I set an additional form params like filename for multipart post?
Is there any way to check a progress of upload using Jetty client? I need a standard thing like a progress bar that shows bytes send, %, etc
Jetty provides a plenty of callbacks like onResponseContent, onResponseStatus, onRequestCommitted, but no one of them could help in monitoring how many bytes have been sent. Is it possible to get an upload progress with Jetty httpclient?
Thank you in advance
You must use MultiPartContentProvider
From: http://download.eclipse.org/jetty/9.3.9.v20160517/apidocs/org/eclipse/jetty/client/util/MultiPartContentProvider.html
A ContentProvider for form uploads with the "multipart/form-data" content type.
Example usage:
MultiPartContentProvider multiPart = new MultiPartContentProvider();
multiPart.addFieldPart("field", new StringContentProvider("foo"), null);
multiPart.addFilePart("icon", "img.png", new PathContentProvider(Paths.get("/tmp/img.png")), null);
multiPart.close();
ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
.method(HttpMethod.POST)
.content(multiPart)
.send();
The above example would be the equivalent of submitting this form:
<form method="POST" enctype="multipart/form-data" accept-charset="UTF-8">
<input type="text" name="field" value="foo" />
<input type="file" name="icon" />
</form>
Use Apache Http client 4.x would help you a bit.
Please see:
http://hc.apache.org/httpcomponents-client-ga/examples.html
I'm working to create an HTML email which includes 2 images. Currently, I'm using tags to place the image in the email. Problem is when users get the email, it's asking the user to "click to download" for security reasons.
Is there a way to embed the image in the email, to avoid this issue?
I'm using Coldfusion to send the email.
Thanks
I haven't tested if this works in e-mail clients, but if you encode the image as Base64 you can include it in the HTML, which avoids the issue of connecting to a remote server.
Here's how you can do this with CFML:
<cfset ImageFile = "/path/to/image.png" />
<cfset ImageInfo = "image/png;charset=utf-8;base64" />
<cfset ImageData = ToBase64( FileReadBinary( ImageFile ) , 'utf-8' ) />
<cfoutput>
<img src="data:#ImageInfo#,#ImageData#" alt="my picture" />
</cfoutput>
You can embed the image as an attachment using cfmailparam and link to the attachement instead of an external file.
http://www.bennadel.com/blog/61-CFMail-CFMAILPARAM-Used-to-Embed-Images-in-Email.htm
I am fairly certain that is an email client issue and not the email/HTML you are putting together. I am unaware (and a quick Google didn't show) of any ways to get around this with HTML.
One possible solution may be to create a rich text email instead and embed the image in the RTF, not sure if that will get you around your issue or not.
Other thought is do you have to have the images in the email? You might be better of crafting the email format to not rely on the images for formatting/aesthetics but allow them to be included if the client displays them. Not sure who your target audience is but in my job we have to deal with users that are restricted to plain text email quite often.