views:

241

answers:

4

I have a web page that displays a list of documents stored on the web site. I need to add a link next to each document that can e-mail it. By that I mean attach the entire document to the e-mail.

When clicking the e-mail link, a 'New Message' window needs to display with:

  • Subject line filled in with the title of the document (displayed on the web page)
  • Contents of the document downloaded from the web site and added as an attachment

The mail client is Outlook. The server is SharePoint (ASP.NET) which contains web services that are able to download files. JavaScript and any JS library is available for use. I'm not able to deploy additional software to the client.

What are my options and are there any references that achieve this type of functionality?

+1  A: 

I can't think of a way to attach the document but you can have a link to fill in the subject and body of an email in which you could add a link to the online document.

<a href="mailto:[email protected]?subject=
[your_subject]&body=[url_encoded_content_string]">New Message</a>

You can use this function to urlencode your body text http://phpjs.org/functions/urlencode

Hope that helps,

Josh

Josh
A: 

Using the HREF mailto, you can make outlook open with the subject at least. I don't know any way to set the body nor an attachment.

From javascript there's no way to automate Outlook using OLE.

<a href="mailto:[email protected]?subject=free chocolate">example</A>

Taken from:

http://www.angelfire.com/dc/html-webmaster/mailto.htm

tekBlues
Yes I know, that's the easy bit
Alex Angas
A: 

I think its been answered before on stackoverflow

http://stackoverflow.com/questions/44421/outlook-email-via-a-webpage

76mel
+1  A: 

An alternative might be to put a link in the body of the message to a place where the file can be downloaded. You could even make it a web page that deletes the file after a set time or number of downloads. To be safe you would need to use "mailto:[email protected]&subject=somesubject&body="+System.Web.HttpUtility.UrlEncode(bodyStringToEncode) to generate an html safe llink

Even with the above answer about launching an email using office automation, you'd still need to first have the file sent to the client, saved in a name and location known to the server, in order to attach the file.

gjutras
Thanks and that would be nice, however the e-mail is being sent outside the company and the link would not be accessible to those users.
Alex Angas
The only other thing I can suggest is to write a page this link opens to, with a form with to: field to be filled in that then sends the email, maybe with a bcc to the sender(checkbox optional?), so it can show in both peoples mail box. If you want to get a little user friendly, remember all the addresses they've used and use an ajax autofill combobox type control for the to: field.
gjutras