Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Sharathmg
Active Contributor
Gmail instead of Outlook mailto:

Google is ubiquitous. Everyone knows Google and uses Google. In fact its become a noun, verb and sometimes as adjective, too. Gmail which was more restricted to personal usage has aggressively made way into the corporate landscape. The cloud adoption has fast-tracked the usage of Corporate Gmail account instead of the traditional thick clients especially Outlook.

In most of our applications the APIs have been adapted to trigger Outlook email. The default URLHelper control triggers the Outlook email. Now, I was stuck with a situation where I had to move the behavior from mailto - Outlook to Gmail.

Some of the options explored where to modify the chrome default handler to Gmail. It Didn't work for me.

Then, I stumbled upon a href- URL which can be built to trigger the gmail. This seemed like a easier way to adapt the code. I had to replace the triggerEmail default function with URLHelper.

My approach was simple:

  1. Prepare the URL to trigger the Gmail.

  2. In the URLHelper, use the redirect method

  3. Pass the URL to the redirect method. Thats it!


The code snippet is as follows:

  1. URL to trigger the GMAIL


// Prepare the Email URL
var sGmailUrl = "https://mail.google.com/mail?view=cm&tf=0" +
(emailTo ? ("&to=" + emailTo) : "") +
(emailCC ? ("&cc=" + emailCC) : "") +
(emailSubject ? ("&su=" + emailSubject) : "") +
(emailBody ? ("&body=" + emailBody) : "");

You can pass the To address, cc and bcc address, email body and subject to the URL.

 

2 and 3. In the URLHelper, use the redirect method. The boolean value true will open the compose window in a separate tab instead of the page in which you are triggering the action.
sap.m.URLHelper.redirect(sGmailUrl, true)

That is all for now.

Please share your queries or feedback's in the comments section.

Regards,

Sharath

 

P.S.: The opinions and content shared in my blogs are purely personal and any resemblance is co-incidental.
Labels in this area