##About Tvhgooglemapi and gmaildrafter are a pair of tools that can be used to make the following menu entries work with google mail without having to install a complete mailclient like Thunderbird or Outlook. File->Send To->Mail recipient (as attachment) (in MS Word) File->Send->Document as email (and the related entries in LibreOffice and OpenOffice.org) File->Attach to email (in Acrobat Reader)
All other windows applications that use Simple MAPI MAPISendMail might work but have not been tested. When installing tvhgooglemapi gmaildrafter is automatically installed. tvhgooglemapi is the part that integrates with windows and gmaildrafter actually uploads the mail as a draft and opens the draft in your default webbrowser. In theory gmaildrafter could also be used to implement other 'send mail' functions.
##Original version and this fork In the original fork, a user was expected to be logged in into a gmail account. The first account defined by:
https://mail.google.com/mail/u/0
is then opened by calling a chrome.exe instance from gmaildrafter.
This is not a proper use case for me, as I've to manage a number of corporate accounts monitored by more than a person. In this case it is possible that you are first logged in into an account but you want to send mail by another account. This situation causes confusion as gmaildrafter pops up a "random" account into a new chrome instance.
Instead we make use of a specific extension (whose code is stored into chrome_extension folder) which monitors the gmail account for new drafts: gmail-draft-monitor. This implies that you must have a registered chrome account and u/0 is your mail.
Moreover the new gmaildrafter is able to store multiple accounts and recal them from a drop-down menu' so you can quick select which account you want to use.
##How it works The new implementation of gmaildrafter uses a google-allowed mail header named: Auto-Submitted. This header is used to store info in the form of: HASH|DATE
HASH is a 32 char random string generated by the chrome extension and stored in local storage. DATE is the string representation of the current date, as of millisecs passed since January 1, 1970, 00:00:00 GMT.
In such a way we can add a unique hash for each installation of chrome where you are logged in with your chrome profile.
gmail-draft-monitor is loadee with chrome and waits in the background that you open a gmail tab. when this happens it starts monitoring your draft folder and pops up the opened tab whenever a new draft is foud being: HASH compliant and recent enough (a param can be set in the bground.js file).
Basically we can pop up the first opened gmail window/tab of the given account in the given seat, avoid confusion among multiple accounts and/or multiple seats monitoring the same account.
##Configuration ###Tvhgooglemapi and gmaildrafter In addition to this code you also need a Java Runtime (at least version 1.8) You can get one here: http://www.oracle.com/technetwork/java/index.html
Imap is used to upload the mail, so you need to enable IMAP in your gmail settings and imaps trafic has to be allowed on the network (port 993.)
The application can't determine the signature of the user. If you want to include a signature in the mails created by this application you can put it in the file %USERPROFILE%.gmaildrafter\signatures\[email protected]
When installing the required registry keys are automatically set. In case you ever need to modify them (ie after temporarily changing the default mailclient) you need the following settings:
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\tvhgooglemapi]
@="tvhgooglemapi"
"DLLPath"="C:\Program Files (x86)\tvhgooglemapi\tvhgooglemapi.dll"
[HKEY_CURRENT_USER\Software\Clients\Mail]
@="tvhgooglemapi"
If a user chooses to store his login credentials these are stored in %USERPROFILE%.gmaildrafter . While the password is hidden an average developer will be able to decode it, so keep these files private and do not store the password on a computer you don't trust.
If you want to automatically attach a signature to your email you can put a file in %USERPROFILE%.gmaildrafter\signatures\[email protected] which contains the text in html. The folder signatures will not be there. You have to create it yourself. Then you need to create a html file in that folder that has as name: matching your email address followed by .html. If you never created a html file there's a quick writeup here: http://csis.pace.edu/~wolf/HTML/htmlnotepad.htm There are many more examples if you google for 'create html file'. Note that if you use images they will have to be online (img src="http:///... it won't work if the image is on your local harddrive. One detail: The file needs to contain at least one html closing tag. (</...>) If this is not the case the program will assume it is plain text and escape all html characters, as a result the entire signature would be on a single line in the final mail.
###gmail-draft-monitor You must build the crx extension file by yourself as you need a number of google related auth IDs and configurations. You do not necessarily need to publish the extension. Once the crx file is created you can drag'n'drop it into chrome.
##Build from source ###Tvhgooglemapi If you want to compile the dll yourself you'll need Microsoft Visual C++ 2010 Express Edition (http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express) and boost (http://www.boost.org/). (Other compilers might work but have not been tested.)
###gmaildrafter The Java application uses Apache Commons CLI (http://commons.apache.org/cli/), Apache Commons IO (http://commons.apache.org/io/) and Apache Commons Lang (http://commons.apache.org/lang/) in addition to the java-gmail-imap implementation of JavaMail (https://code.google.com/p/java-gmail-imap/). The sources include a Netbeans Project, but another ide should do just fine.
As of 2016-03-21 the current fork has been updated to compile with latest stable version of java dependancies, along with netbeans 8.1 (JDK 1.8) Dll has been patched/adjusted to compile on win10 (32-bit target) under VC++ 2015 with boost 1.60 Also note I've not committed path to libs on my machine: you have to reasign dependancies position for both java and c++
###gmail-draft-monitor The chrome extension guide by google is a good starting point to learn enough to package and public your extension:
https://developer.chrome.com/extensions/packaging#upload
while here it is explained how to get your auth ID and quotas for the google api services (used by the extension):
https://support.google.com/cloud/answer/6158857?hl=en
https://developers.google.com/identity/protocols/OAuth2#basicsteps
what you need is basically to: 1- enable the gmail javascript api 2- create an API key 3- create credentials for your crx extension
###Installer The installer is made with innosetup. Code is gone to be deployed on Win7/8.1/10 machines mostly 64-bit.
##Bug reports If you have issue with the present fork, please consider that I have no time to support it for other applications than mine.
If you have a problem with the original application please report them at https://github.com/jankeirse/tvhgooglemapi/issues If your problem refers to gmail exit code 1 please create a file in c:\windows\temp\debuggmaildrafter.txt , try to send a mail again and when there is a popup 'Going to execute the last command in c:\windows\temp\debuggmaildrafter.txt' before confirming this popup, open the file c:\windows\temp\debuggmaildrafter.txt and run the last line in dos (Start->execute->cmd.exe) It will most likely provide valueable information.