title: In a rails 3.0 app I'm having trouble embedding an image in an email
body: <p>I am trying to get a QR Code image to display in an email. I have tried to apply solutions from similar questions here at SO but have not been able to get any variation of them to work. I don't want to download it from the site.</p>
  
  <p>in my user_mailer.rb:</p>
  
  <pre><code>  def email_qrcode(from_whom, to_addy)
      @from_whom = from_whom
      @to_addy = to_addy
      attachments["qrcode.png"] = File.read(Rails.root + "public/images/qrcode.png")
      mail( :to =&gt; to_addy, :from =&gt; @from_whom.email, :subject =&gt; "QR Code" )
    end
  </code></pre>
  
  <p>in my email_qrcode.html.erb:</p>
  
  <pre><code>  &lt;body&gt;
      &lt;p&gt;Here is the QR Code:&lt;/p&gt; 
      &lt;p&gt;&lt;img src="cid:qrcode.png"&gt;&lt;/p&gt;
    &lt;/body&gt;
  </code></pre>
  
  <p>The email content that is displayed:</p>
  
  <pre><code>Here is the QR Code: (followed by the little blue question mark indicating no image)
  </code></pre>
  
  <p>It is also included as an attachment, but having to double click it to open it defeats the convenience factor.</p>
  
  <p>Thanks for your help.</p>
  
  <hr>
  
  <h2>UPDATE:</h2>
  
  <p>Good marketing is about removing every obstacle that you can to make it easier for the potential customer. The more times the QR code is displayed without having to find and click another link, the better the results will be. So, to be clear...</p>
  
  <ol>
  <li>The attachment is there. In some email clients web mail servers it will even display as an attachment below the email. However, many (maybe most... not sure) email clients and web mail servers will not display an attachment unless you click on them to open them... another click (obstacle).</li>
  <li>In addition, many clients and web mail servers will prevent the download and display of images without clicking on a link to approve display of the image. However, many of those clients and servers will NOT block an image that is embedded in the email. In other words putting in a link to download the image increases the likelihood of the display being blocked requiring a click (obstacle to potential customer) to open the image.</li>
  </ol>
  
  <h2>ANOTHER UPDATE: solution</h2>
  
  <p>user_mailer.rb:</p>
  
  <pre><code>attachments.inline["qrcode"] = {
                                  :data =&gt; File.read("#{Rails.root.to_s + '/public/images/qrcode.png'}"),
                                  :mime_type =&gt; "image/png",
                                  :encoding =&gt; "base64"
                                }
  </code></pre>
  
  <p>email_qrcode.html.erb:</p>
  
  <pre><code>&lt;%= image_tag( attachments['qrcode'].url, :id =&gt; 'qrcode' ) %&gt;
  </code></pre>