Version 2 of the Gmail to Evernote script has been released. The new version adds text on top of the message in Evernote, with the basic headers from the email message (From, To, Date) and a link back to view the message in Gmail. For example, if you forwarded the message to a task list in Evernote, you can now quickly send a response after completing the task. No more searching in Gmail to find the message back!
There are more changes, and you have to do some extra configuration steps if you use multiple sign-in for Google, because in that case, the link to the Gmail message is not always correct.
This version will send email notifications when a new version is available. If you are running the script directly from bit.ly/gmailevernote, you don’t need to update, and you will not receive a notification, unless some other action is required or relevant information can be given.
If you made your own copy of the script, you will always receive a notification of new versions, so you can replace your copy with the new version.
You may have to authorize and grant access again, see the previous update on Gmail to Evernote.
Configuration
For basic configuration, see the original post on Gmail to Evernote.
Multiple sign-in
If you use multiple sign-in for Google, there is no single URL for an email message. For a message with ID 12345abcd, there are two possible URLs:
- The regular one, copied from the address bar in Gmail:
https://mail.google.com/mail/u/0/?shva=1#inbox/12345abcd
- From the RSS feed (https://mail.google.com/mail/feed/atom), it looks like:
http://mail.google.com/mail?account_id=example@gmail.com&message_id=123456abcd&view=conv&extsrc=atom
The first method only works with the first account that you used to sign in (default account). If you signed in with more accounts, the link will be https://mail.google.com/mail/u/1/?shva=1#inbox/12345abcd
for the second account, etc. So the link to an email message may be different if you signed out and sign in again in a different order, or work in a different browser.
The second method looks more promising, as it uniquely identifies both the account and the email message. However, it turned out that this only works if the account is the same as the default account. Technically, I don’t understand why this does not work, it should not be too difficult for Gmail to check whether the account is one of the signed-in accounts and use this account, so I assume this is a bug, or an oversight from the folks at Google.
Thanks to Mo’in Creemers for pointing me to the second URL format. Now it is up to Google to make this work!
Work-around
The Gmail to Evernote scripts adds a link in the first format to Evernote. As mentioned, this only works for the default account. If you use multiple sign-in, you can configure the script to also present alternative links, like:
https://mail.google.com/mail/u/0/?shva=1#inbox/12345abcd - user 1 - user 2 (example@gmail.com)
You can change the number of users in the User properties (under File – Project properties), set the value for gm2en_nacct to the number of accounts.
Header fields
In the new version, email header fields are also added to Evernote. In the note, you can now see who send the email, to whom, and when. Other fields are also possible, by changing the value for the gm2en_fields user property. This is a comma-separated list of the fields that will be shown.
By default the value is ‘From, To, Cc, Date’. Fields are only shown if they have content, so if there are no Cc-addresses, this header field will not be shown. Other fields that you can include are: Bcc, ReplyTo, and Subject.
If you don’t want any header fields, set the value to an empty string, ”. If you also set the value for gm2en_nacct to 0, the link to the message in Gmail will not be shown either.
Style
You can configure the CSS style for the header DIV, containing the header fields and the link(s). By default, it is set to ‘border-bottom:1px solid #ccc;padding-bottom:1em;margin-bottom:1em;
‘ showing a light-grey line between the header and the message. You can change this by editing the user property gm2en_hdrcss.
More changes
The names of the user properties, that are specific for this script, have been changed and now have a prefix gm2en_, to avoid any confusion with other scripts.
This post is also available in: Dutch
Thanks for the amazing script.
One of my notebooks is called 1-PRIMARY/PENDING. This appears to confuse the script. The emails with that tag are delivered to my default notebook instead, with ” @PENDING” appended to the note title.
I can’t tell if all emails were successfully forwarded, as it seems emails moved by the script don’t appear in my Sent folder. That might be a useful change. In the meantime I will change my notebook name and tag to eliminate the dash and slash, and see if that helps.
I received a “Summary of Failures” email from Google Apps Script this evening, with this one entry:
Start Function Error Message Trigger End
4/6/13 8:42 PM readEvernote ReferenceError: “mailInfo” is not defined. (line 277, file “Code”) time-based 4/6/13 8:42 PM
Thoughts?
Thanks again for your time and all your great work.
Warmly,
Rafter
Hello Rafter,
Thanks for your feedback!
The confusion about the 1-PRIMARY/PENDING label is because the way Evernote shows the names of the labels to a script. If you have a label Evernote, and a sublabel 1-PRIMARY, it will show as ‘Evernote/1-PRIMARY’. Another sublabel PENDING under 1-PRIMARY, would shows as ‘Evernote/1-PRIMARY/PENDING’, which is exactly the same as when you have a sublabel 1-PRIMARY/PENDING directly under Evernote. So the script can not distinguish between both.
Actually, Google Mail itself also has problems making the distinction. If you would try to create a label 1-PRIMARY next to 1-PRIMARY/PENDING, you will see that the label 1-PRIMARY/PENDING is converted to a sublabel PENDING under 1-PRIMARY
So the lesson here is not to use the slash ‘/’ in your Gmail labels, and if you use the script, also don’t use slashes in Evernote tags or notebooks.
Indeed the messages sent to Evernote do not appear in the Sent folder. You can tell if the messages are sent by checking the log sheet.
The mailInfo error is the result of a bug, remaining from a change I made in an earlier version. It will be fixed in the next version, which is almost ready, expect to be released tomorrow.
Kind regards,
Harry
Hello,
Thank you very much for your great script.
Things went wrong for me on my very first attempt but before I give you a full briefing I have one important question:
Question: Is it possible to use the advance features of your script so that Evernote reads the actual age of the gmail and NOT the date the script actually transferred gmail to Evernotes?
If the answer to the question above is NO, is it possible to set up some advance feature of the script so that it only transfers brand new gmail to Evernote? This way both the transfer date and the actual age of the gmail will align. I am willing to give up or sacrifice yesterday’s and older gmail.
I look forward to your response.
Thank you very much.
Best
Yikes
Hello Yikes,
Getting curious what went wrong. Something that can be avoided by better documentation?
The script uses the GmailApp.sendEmail function of Google Apps Script to send an email message to Evernote. Using this function it is not possible to set the date explicitly. Therefore, Evernote will always read the date that the message is sent.
I tend not to include too many features, that are of interest to only few people–that would make the script unnecessary heavy and complicated. But the good thing of such scripts is that you can just create your own copy from the source and adapt where necessary to suit your needs. In this case, edit the file ReadMail.gs, add a few lines early in the function readEvernote(), around line 45:
and around line 67:
Note: this code is not tested, so I can not guarantee it works literally as written here.
Thanks Harry,
I will report back to my findings.
Best
Yikes
I realize this is an old thread (and I’m not sure if the script is being updated anymore), but has anyone successfully incorporated this script modification in order for notes to be dated according to the gmail date stamp?
The script works by sending an email to Evernote. This page list all you can do by sending an email to Evernote. Setting the date of a note is not an option, so it is not possible to do that using this script.