0

I want to send email using mailto tag with a single pdf file as attachment. mailto tag opens the mail window with passed arguments like to and subject using:

<a href="mailto:<%=@user.mgremail%>?subject=Expense Report&attachment='<%=fileNameW%>'">Mail to Manager</a>

But, attachments as a parameter isnt working. Please suggest how to send pdf attachment in rhomobile.

Thanks

corthmann
  • 377
  • 1
  • 2
  • 9
Priya Saini
  • 109
  • 13

1 Answers1

0

I think that you need to add the physical path to the PDF file for it to work (otherwise it may not know where the file is). This post on a forum says as follows:

The only problem is that this "mailto" command executes on the client machine, therefore it tries to locate the attachment file by a physical path, and not by a virtual path.

That is,

  1. Using mailto:iudith.m@zim.co.il?subject=my report&body=see attachment&attachment="\myhost\myfolder\myfile.lis"

    works ok, but only for local users (those connected to the same network as the "myhost" machine).

  2. Using mailto:iudith.m@zim.co.il?subject=my report&body=see attachment&attachment="http://myhost:myport/my_location_virtual_path/myfile.lis"

    does not work, it does not recognize such a syntax as valid for the attachment file.

In your case you would properbly need to look at this part of the Rhomobile docs (on file system access) to get the right path to your file.

EDIT:

From you comment I can see that you are trying to make it work on iOS (due to the iOS specific path).

In this discussion (from Rhomobile's Google Group) it is explained that mailto doesn't support attachments on iOS. It says as follows:

Don't know about other platforms, but you cannot do this on iOS. mailto: does not support attachments on iOS.

You can do it using a native API, MFMailComposeViewController.

This is a complete controller with UI, so you would have to write a Native View Extension to use it:

http://docs.rhomobile.com/rhodes/extensions#native-view-extensions

EDIT 2:

I've looked around and it seems that mailto doesn't support attachments on Android either. This is because Android supports the RFC 2368 mailto protocol, which doesn't include attachments. Here is a reference to the Android mailto url parser.

I would suggest that you do as suggested for iOS, write a native extension. I think this post would be relevant for you.

Community
  • 1
  • 1
corthmann
  • 377
  • 1
  • 2
  • 9
  • I am giving the complete path but it isnt working. Code is like: <% fileNameW = File.join(Rho::RhoApplication::get_user_path(), 'demo.pdf')%> Mail to Manager – Priya Saini Nov 19 '12 at 02:46
  • Couldn't figure out what made you think i am doing this for ios. I am developing an Android app on Rhomobile. – Priya Saini Nov 20 '12 at 07:00
  • As far as I can see, the 'Rho::RhoApplication::get_user_path' is iOS specific. It is only mentioned under "Rhodes client file system structure on iOS platform" in the Rhodes documentation. Maybe that is your problem ? – corthmann Nov 20 '12 at 10:02
  • It is working for me at other places as well. Still i tried giving the static path as well but neither it returns any error nor it recognizes the attachment. Do you know any other alternative for this? – Priya Saini Nov 20 '12 at 11:58