1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need inline images in CFMAIL

Discussion in 'Programming' started by Keith Eckhardt, Jun 21, 2007.

  1. #1
    I'm stuck. I can't figure out how to embed an inline graphic in a CFMAIL message. I just need a clue.
     
    Keith Eckhardt, Jun 21, 2007 IP
  2. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Let's see what you have so far - the answer could be right there

    However it doesn't sound like you have a CF problem, it seems like you have a CSS problem.

    In your img tag you could place style="display:inline;". However I have the feeling that may not be what you are looking for. Post what you've got thus far.
     
    datropics, Jun 21, 2007 IP
  3. newbish

    newbish Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't believe cold fusion can do a "true" inline image. (Inline mail images that are embedded into the mail message the image it self does not sit on a server. When downloaded from the server they are renamed and displayed within the message. This is a common practice of spammers these days.) The closest I believe you will be able to get short of using a third party SMTP library is going to be linked images off a website.
     
    newbish, Jun 26, 2007 IP
  4. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Another option is to create a PDF File and then embed it in the email message. As in

    1) create your document ( <cfdocument .... )
    2) Embed in your mail message (<cfmail ..... > <cfcontent ...> )

    I've never actually tried it, but give it a shot, who knows.

    newBish - that's a good point you have. Maybe we're missing something because I'd like to think that it is possible, maybe we just don't know how - oh well - that's why were're here...to help each other out!

    HTH

    daTropics
     
    datropics, Jun 26, 2007 IP
  5. newbish

    newbish Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ive done something similar to this before and was forced to leverage the JavaMail API in a CFC to accomplish the task. Something I don't recommend for the faint of heart. It took months to get it right, I probably could have bought a third party application for under 200, and in retrospect should have.
     
    newbish, Jun 27, 2007 IP
  6. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #6
    but where's the fun in doing that?!!! :)
     
    datropics, Jun 28, 2007 IP
  7. cschmitz

    cschmitz Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ColdFusion can create "true" inline images in mails since CF7. You need to use the <cfmailparam> tag:

    
    <cfmail to="#yourAddress#" from="#myAddress#" subject="#subject#" type="html">
       <p>This is HTML-formatted mail with<p>
    
       <img src="cid:theImg" width="350" height="263" alt="" />
    
       <p>inline images</p>
    
       <cfmailparam file="C:\data\myfile.jpg" contentID="theImg" disposition="inline" />
    </cfmail>
    
    Code (markup):
    The file is attached to the mail, but, displayed inline by reference to the contentID. Please note the reference to the cid: in the <img> tag's src attribute.

    HTH,

    Chris
     
    cschmitz, Aug 2, 2007 IP
  8. newbish

    newbish Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Good to know I just found this out the yesterday while fixing an IMAP cfc I had written and thought wow ok I was wrong, I need to find that post. :)

    Good to see that some people are keeping up with what has been added in more recent versions ;)
     
    newbish, Sep 23, 2007 IP
  9. elizas

    elizas Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ile (CFMAILPARAM attribute) - This attaches a file to the email. This should be an absolute path where the actual file resides.
    contentid (CFMAILPARAM attribute) - An unique identifier for the attached file. This is normally used to identify the file in the mail body that references the file content.

    In the above example, we are using the “contentid” we provided in CFMAILPARAM tag as IMG tag cid which is the content id. Instead of providing the content id if we provide the path to the image file, then the image is sent as an attachment. Since we have used the content id, instead of being rendered as attachment, the content of the file with the id provided gets embedded into the email content. The CFMAILPARAM tag can also be used to include an image from an external link.
    Advantage: It will not give an impression like phishing attack or spam email.
    Disadvantage: It might take little more time to load the body of an email as we might have heavy images embedded.
     
    elizas, Apr 22, 2010 IP
  10. elizas

    elizas Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    file (CFMAILPARAM attribute) - This attaches a file to the email. This should be an absolute path where the actual file resides.
    contentid (CFMAILPARAM attribute) - An unique identifier for the attached file. This is normally used to identify the file in the mail body that references the file content.

    In the above example, we are using the “contentid” we provided in CFMAILPARAM tag as IMG tag cid which is the content id. Instead of providing the content id if we provide the path to the image file, then the image is sent as an attachment. Since we have used the content id, instead of being rendered as attachment, the content of the file with the id provided gets embedded into the email content. The CFMAILPARAM tag can also be used to include an image from an external link.
    Advantage: It will not give an impression like phishing attack or spam email.
    Disadvantage: It might take little more time to load the body of an email as we might have heavy images embedded.
     
    elizas, May 7, 2010 IP
  11. elizas

    elizas Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Using CFMAIL tag attributes we provide all the details for sending an email programmatically like TO, FROM, MAILSERVER etc. The body of the email goes in between the starting and ending tags of CFMAIL. CFMAILPARAM (sub tag for CFMAIL) in ColdFusion is normally used to attach a file or add a header to a message. Using this tag, we can send embedded images in an email.

    Example Code:

    <cfmail
    to="{recipient email address}"
    from="{sender email address}"
    subject="Embedded Image Example"
    type="html">

    <h2>Image Embed Example</h2>

    <p><img src="cid:img_id" width="300" height="300" alt="" /><br /></p>
    <!--- Embed image from the local file system --->
    <cfmailparam
    file="{path to the image file}"
    contentid="img_id"
    />
    </cfmail>

    Hope u find this tip interesting.
     
    elizas, Jun 17, 2010 IP
  12. Alexandros1

    Alexandros1 Peon

    Messages:
    332
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I did not know this, but apparently in ColdFusion MX 7, the CFMailParam tag can be used to embed images directly into the email content. After some initial testing, it seems this is completely true and very exciting! It is almost too easy.
     
    Alexandros1, Jul 6, 2010 IP
  13. rajanrufus

    rajanrufus Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #13
    Thanks for your sharing.
     
    rajanrufus, Dec 27, 2011 IP