I am new to coding and have been trying to enhance a Google Sheets project by adding automated email reminders through Google Apps Script.
In this, I was trying to attach to the reminder email one or more Google Drive files which are best referred to through their URL(s), inserted as links in specific cells.
I tried things like range.getRichTextValues()[1][1].getLinkUrl()
but none worked.
Any help much appreciated!
Asked
Active
Viewed 857 times
0
-
1Hi AngVas, if it's just a URL in the form www.example.com, then `range.getValue()` should return the text. If there is a reason why that doesn't work, maybe you could show us exactly what the cell contains. Also, can you clarify if you are just asking for help with Sheets, or do you need help with Drive and Mail as well? (If you do, edit the question) – dwmorrin Jul 17 '20 at 03:00
-
Thanks, @dwmorrin! I guess the matter is that the URL is not the text value in the cell but a link inserted in the cell (using the "insert link" menu function in Google Sheets). I didn't find a way to reference this link and what seemed closest was through that range.getRichTextValues()[1][1].getLinkUrl() combination. Obviously not working, though. I think the core issue so far lies with Google Apps Sctipt run on Google Sheets. – AngVas Jul 17 '20 at 17:44
-
Does this answer your question? [Apps Script: how to get hyperlink from a cell where there is no formula](https://stackoverflow.com/questions/53863752/apps-script-how-to-get-hyperlink-from-a-cell-where-there-is-no-formula) – Iamblichus Jul 20 '20 at 07:50
-
I'm afraid not. – AngVas Jul 24 '20 at 01:10
1 Answers
0
Try something like this:
GmailApp.sendMail(recipient,subject,message,{attachments:DriveApp.getFileById('fileid')}
id=url.slice(url.indexOf('/d/')+3,url.indexOf('/edit'));

Cooper
- 59,616
- 6
- 23
- 54
-
Thanks, @Cooper! I guess my problem is I can only reference the file to attach by its URL that is only available as a link inserted in a spreadsheet cell using the "insert link" menu command in Google Sheets. Do you know a method to get a link specified in this way? Thanks! – AngVas Jul 24 '20 at 01:14
-
-
I really appreciate your trying to help and I seem to fail explaining the core issue. Here is a retry: I don't know how to extract the URL from the cell. Please note that the URL is not available in the text value of the cell but is rather inserted as a link using the "insert link" menu function in Google Sheets. – AngVas Jul 27 '20 at 23:07