1

I have been trying to send attachement with mail using angular8. Tried following code a href="mailto:youremail@email.com?attachment=<your filepath>" Path looked like this C://Inetpub/wwwroot/myfile.pdf But, This just opens up an empty outlook without attachments. Any help will be appreciated.

1 Answers1

0

As far as i know, it is not possible to do so. Mail-To links are not supporting attachments.

Because what you're doing here, is you create a link, and because of the beginning 'mailto:' your browser knows that this should end with an e-mail. So it opens up your standard mailing app/programm, with a new mail to the given mail-address. It's not sending the E-Mail, so there's also no way to get data from your server. If you really want to attach something to the e-mail from the server, you will need to send the mail via a Backend-Service (PHP, Java...). There are planty of libraries to make this easy.

Andreas Rainer
  • 314
  • 4
  • 16
  • Thanks for reply. The file is not from server but an exported .csv file that would be downloaded and sent along with email as an attachment from my local machine. – Akshay Dhiman Jul 13 '20 at 13:24
  • Without a backend there's no way to go i think... Do you use a backend already in your application? – Andreas Rainer Jul 13 '20 at 13:28
  • Yes SQL Server and web api to fetch data. – Akshay Dhiman Jul 13 '20 at 13:30
  • You mean .net Web-Api? You could upload the csv-file to your API and send the e-mail from your backend. Then you can define one E-Mail adress, your application will send this mail + attachment from. I think this would be the best way to do it – Andreas Rainer Jul 13 '20 at 13:51
  • But what if the email address to whom the attachment will be send is not defined or depends on user wish. Are you suggesting silent sending of emails? – Akshay Dhiman Jul 13 '20 at 14:01
  • You can always do some sort of Interface. For example you could ask your user, to whom the e-mail should be sent, with which text and transmit this information together with your attachment-file via http-call (put-method) – Andreas Rainer Jul 13 '20 at 20:40