Skip to main content
Inspiring
March 27, 2010
Question

Paste an image in a CFmail

  • March 27, 2010
  • 1 reply
  • 1830 views

When using

a Mail user Agent (Outlook for example), we can paste an image inside the body of the mail,

which is great to show something to someone else rapidly.

Is there a way for doing the same thing using CFmail,

I know the cfmail boby will take the content of a textarea or an HTML online editor, from a form,

and we cannot paste an image in these 2 cases.

So how to make a webmail with CF as powerfull as another mail agent ?

to rapidly paste an image in the body ?

If I save my image in local, then I upload to the server, then I can reference to it,

but this is too long and too heavy.

Thanks for any help with this ?

Pierre.

This topic has been closed for replies.

1 reply

Fernis
Inspiring
April 6, 2010

Outlook is an email client. CFMAIL is not, in any way. CFMAIL can take any ColdFusion variable contents as the mail body.

You can compose HTML emails with inline images, however, with CFMAIL.


<cfset myImgPath = expandPath('./') & "pics/">

<cfmail from="address@domain.com" to="recipient@domain.com" subject="Inline image test">

I should see a sunrise image below:<BR/>

<img src="cid:img1"><BR/>

and a moon below:<BR/>

<img src="cid:img2">


<cfmailparam disposition="inline" contentid="img1" file="#myImgPath#sunrise.jpg">

<cfmailparam disposition="inline" contentid="img2" file="#myImgPath#moon.jpg">

</cfmail>

You need to have the images on the ColdFusion server side before you can embed them into the email. If you use a ColdFusion server-side component as a WYSIWYG editor, such as fckeditor or ckeditor, just make sure the images are loaded up from the server side. Then it's just a matter of parsing the email content so that the <img> tags point to embedded cid: objects instead of server urls - and assigning each image an identifier with the cfmailparam tag. But I'm not going to go into details on that one.

--

-Fernis - fernis.net - ColdFusion Developer For Hire

plartsAuthor
Inspiring
April 6, 2010

Thanks for this answer,

So in any case, the user need to save his image (local) and upload to the server,

before being able to insert it in an online editor and send it.

I think it is not possible

Only if people from FCKeditor and CF adobe work together to make it works,

may be ?

Is this true ?

People want the most easy way. So just paste and send.

Like in an Email agent.

(no save, no upload, then compose your mail and send)

Thanks, may be a future functionnality ?

Fernis
Inspiring
April 6, 2010

There is no reason this should be a future functionality, since it's totally out of ColdFusion's scope as a server side solution to act as a client-side e-mail application.

When you are using Outlook, for example, you tell Outlook to search files from somewhere, whether it's a drag-drop action or not. This is already virtually the same thing as running ColdFusion on the same machine where you have the images. You are already using a dedicated software application to handle images on the same machine where the images are AND where you send the e-mail from.

In order to have seamless copy-paste on your local images, and have them sent from the server side, fckeditor (which runs client-side on Your computer) would need to "steal" the images from your DOM model without anyone noticing, and upload them to the server side. Browsers do not allow this due to security concerns.

The only way to go around this is using dedicated flash/java applets for email editing or image uploading on your browser, or browser extensions (such as Google Gears)

So, if you forget security, browser compatibility, etc., you might be interested in this:

http://fvisticot.blogspot.com/2009/06/google-gears-desktop-drag-and-drop.html

-Fernis - fernis.net