0

I'm an experienced back end java developer, but newer to Salesforce and front end development.

I'm trying to implement this MailGo JS Library to handle our :mailto links a little prettier than just forcing open the default mail client on the machine. This is in a fully custom aura web app.

I imported the library successfully into my cmp. I see it load in the console successfully on page load.

<ltng:require scripts="{!join(',',
    $Resource.mailJs +'/mailGo.js',
    $Resource.x,
    $Resource.y)
}" afterScriptsLoaded="{!c.scriptsLoaded}"/>

The docs say:

"After any type of installation, by default all the mailto: links will be enabled with mailgo automatically"

so I created a basic <a> tag in my code to test but it just opens the outlook app on my machine, not the modal that's supposed to pop up.

<a href="mailto:[email protected]">Email Crew</a>

Expected result:
enter image description here

actual result: the outlook application is opened on my machine.

anyone have any experience with something like this? Am I missing something specific to Aura Components?

2
  • 1
    I know nothing about MailGo, but my hunch is that the library needs to be able to access the DOM in order to attach event listeners to elements on it and prevent the default handling of a mailto:. With Aura and Lightning components, you are explicitly not touching the DOM unless under specific circumstances. If you only want to use this in one component, I would see if there's an API for MailGo that lets you call the modal in another way than letting the library attach listeners.
    – nbrown
    Commented Apr 15, 2022 at 17:12
  • @nbrown you nailed it. found a way to call the modal directly. got it working! Commented Apr 20, 2022 at 16:14

1 Answer 1

1

Per nbrown comment above, I was able to find a way to call the modal directly.

mailgoDirectRender(link);

Where link is your mailto: string.

mailgoDirectRender('mailto:[email protected]?subject=Crew Updates')

ended up working like a charm.

If someone comes across this answer and is having problems with multiple email addresses, they must be separated by commas ',' and not semi colons ';'. This is not explicitly indicated in their documentation, but their examples only show them being separated by commas.

1
  • 1
    Glad you figured it out! The mailto spec is a standard (see RFC 6068) and the spec may help you out with formulating more complex URIs
    – nbrown
    Commented Apr 20, 2022 at 17:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .