# Attaching, literally, a link

**URL:** <https://www.ruby-forum.com/t/attaching-literally-a-link/184802>\
**Category:** Rails\
**Created:** [March 8, 2010, 9:41pm UTC](https://www.ruby-forum.com/t/attaching-literally-a-link/184802 "2010-03-08T21:41:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![theduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@theduz](https://www.ruby-forum.com/u/theduz)\
**Post date:** [March 8, 2010, 9:41pm UTC](https://www.ruby-forum.com/t/attaching-literally-a-link/184802/1 "2010-03-08T21:41:17Z")

</div>

Hi,

I’m trying to avoid sending large PDF’s via email. My current  
strategy is to put a link to the document or web page into the e-mail,  
and it works just fine, but I’m getting complaints that “the  
attachment is missing”. Is there a way to have a link show up as an  
attachment?

I’ve tried to use the RFC 2017 strategy of using content type message/  
external-body, but I don’t think rails is formatting the attachment  
quite right, or maybe outlook (majority of receivers use outlook)  
doesn’t understand it?

```
part :content_type => "multipart/alternative" do |a|
  a.part "text/plain" do |p|
    p.body = render_message 'mailing.text.plain.rhtml', :mailing

```

=\> mailing  
end

```
  a.part "text/html" do |p|
    p.body = render_message 'mailing.text.html.rhtml', :mailing

```

=\> mailing  
end  
end

```
attachment :content_type => "message/external-body; access-

```

type=URL;" do |a|  
a.transfer\_encoding = “binary”  
a.body = “URL="[http://www.biltd.com](http://www.biltd.com)"\n\nContent-type: text/html  
\nContent-Transfer-Encoding: Binary\n\nTHIS IS NOT THE BODY!\n”  
end

Produces, in part:

–mimepart\_4b955ae181878\_1b83faad4933fb41189  
Content-Type: message/external-body; access-type=URL  
Content-Transfer-Encoding: Binary  
Content-Disposition: attachment; access-type=URL

URL=“[http://www.biltd.com](http://www.biltd.com)”

Content-type: text/html  
Content-Transfer-Encoding: Binary

THIS IS NOT THE BODY!

–mimepart\_4b955ae181878\_1b83faad4933fb41189–

Which doesn’t look quite like RFC2017 shows. There seems to be an  
extra new line, and a couple extra headers. RFC2017 expects the mime  
body to look like:

Content-type: message/external-body; access-type=URL;  
URL=“[http://www.foo.com/file](http://www.foo.com/file)”

Content-type: text/html  
Content-Transfer-Encoding: binary

THIS IS NOT REALLY THE BODY!

Suggestions appreciated.

Thank you.

Regards,  
Rich

---

<div class="post-metadata">

**Author:** ![theduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@theduz](https://www.ruby-forum.com/u/theduz)\
**Post date:** [March 8, 2010, 10:04pm UTC](https://www.ruby-forum.com/t/attaching-literally-a-link/184802/2 "2010-03-08T22:04:42Z")

</div>

On Mon, Mar 8, 2010 at 3:40 PM, theduz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> attachment :content\_type =\> “message/external-body; access-  
> type=URL;” do |a|  
> a.transfer\_encoding = “binary”  
> a.body = “URL="[http://www.biltd.com](http://www.biltd.com)"\n\nContent-type: text/html  
> \nContent-Transfer-Encoding: Binary\n\nTHIS IS NOT THE BODY!\n”  
> end

> Content-Transfer-Encoding: binary
> 
> THIS IS NOT REALLY THE BODY!

Not tested:

attachment :content\_type =\> “message/external-body; access-  
type=URL; URL=URL="[http://www.biltd.com](http://www.biltd.com)"” do |a|  
a.transfer\_encoding = “binary”  
a.body = “THIS IS NOT THE REAL BODY!\n”  
end

–  
Rick DeNatale

Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
Twitter: [http://twitter.com/RickDeNatale](http://twitter.com/RickDeNatale)  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)
