Send an email through Salesforce server from External Application - javascript

I have an angular application, and wants to send an email to Salesforce contacts from external application through salesforce server.
I did not find any api or javascript file which allows me to write the code to send an email through salesforce server from external application.
Thanks.

You can use sendEmail() to send one or more emails via Salesforce. It can be either a SingleEmailMessage or a MassEmailMessage.
MassEmailMessage is more useful if you are dealing with a collection of Contacts, Leads or Users. See What's the Advantage of using MassEmailMessage instead of multiple SingleEmailMessage?

Related

Use API in JS safety

I've always use JS framework coupled with a PHP backend on the same server (website in php who use a JS framework like react/vue/angular).
I know how call an API function with axios (from JS to my PHP backend) for insert/select in database. I've a environement file who contains login and password for the database, I use it in PHP.
But I want to make an vue app without integrated it in a webpage PHP. (for convert it in electron and ionic).
So the files are in user disk.
How can I call my own API (ex: http://my-custom-api.test/api/insert_data) without users see a password or another stuff for login himself to my api) => Only my apps are allowed to use API
EDIT: Ok for this step, I use a token system.
But i've one question, a user can be exposed to CSRF attack ? (Client is a electron desktop app or Ionic mobile app). They call my api for execute action with params (form data and token bearer user). It's safe ?

How to receive templates from user to send a email?

I'm making a service where a client of my service can decide what template they use when sending an email to a user.
I'm using pre-defined templates.
I'm working on node.js and using "email-templates" module for setting the template.
I want to receive the template from the client and use that template in sending their mail to give them a more personalized experience.
So, Can anyone help me with that?

Service for email form for a webpage

I need to put "contact us" form on a static webpage. I want to create the form myself, but I can't send emails from JavaScript. However, I can send HTTP requests. So I want to send request with all the data necessary to some service, and I want this service to send me an email.
I know SendGrid or Mandrill, but I don't want to create a gate for spammers. Obviously, if I used services like this my API-KEY would be publicly accessible in JS files. Unless it is possible to limit this services to send emails only to one address, but I couldn't find such option.
Another options are http://kontactr.com/ or http://www.emailmeform.com but they offer whole web form, and send complicated requests with some ID, which doesn't work when sent again. I.e. I can't forge working request myself. Also, Kontactr comes with captcha, which I don't want and can not remove.
Do you know any simple service I could use? I want it to be as simple as possible - just data in a request which then are sent to my email.
You can achieve this using SendGrid and Parse as outlined in this blog post: https://sendgrid.com/blog/send-email-static-websites-using-parse
Using Parse allows you to keep things like your SendGrid API key a secret.
Additionally, you can make it more spam resistant by adding a Captcha, either something you create yourself, or some of the services out there (reCaptcha, Sweetcaptcha, or others).

Read Outlook messages with JS app?

I would like to access a user's Outlook emails with my javascript app.
Google makes this very easy using Oauth and it's restful Gmail API.
I have tried researching similar options for Outlook, but I can't seem to find a good way to authenticate a user with Oauth 2.0, then access their message inbox.
Are there any Microsoft technology experts that can point me to some resources to get started here?
I am restricted to using only client-side code as this is for a phonegap mobile application. I would like to continue using oauth-io but I realize that may not be an option.
I was having a hard time tracking down the process for getting the emails as well. Anyway, first things first, you'd need to register your app for OAuth here. This page describes some more details on the registration and also how to access the needed API.
Although you can do the calls via Javascript, there are some security issues because you'd eventually need to send your client secret. It might be safer to do some parts in the server side.
First step is getting the user to login and retrieving the access token.
https://login.live.com/oauth20_authorize.srf?client_id=[CLIENT_ID]&scope=wl.imap wl.offline_access&response_type=code&redirect_uri=[REDIRECT_URI]
On the server side, exchange the access code for an access token:
https://login.live.com/oauth20_token.srf?client_id=[CLIENT_ID]&client_secret=[CLIENT_SECRET]&code=[ACCES_CODE]&grant_type=authorization_code&redirect_uri=[REDIRECT_URI]
Get user's email and other account info (Python sample codes):
https://apis.live.net/v5.0/me?access_token=[AUTH_TOKEN]
Retrieve emails via IMAP using the email address from emails>preferences in previous reply (see more details here). It would look something like this in Python:
import imaplib
mail = imaplib.IMAP4_SSL('imap-mail.outlook.com')
username = [username]
access_token = [access_token]
auth_string = 'user=%s\1auth=Bearer %s\1\1' % (username, access_token)
mail.authenticate('XOAUTH2', lambda x: auth_string)
mail.list()
You can look at existing IMAP libraries to retrieve the actual emails from there. Here's one for python.

How can I authenticate with Wufoo to access their API from Java Script?

I am trying to access the data from a form, so that I can use it in a custom application.
I need to be able to this in HTML, so I would like to use Java Script.
How would I send the API key(which is the username) and the password to Wufoo so that I can then access the JSON file that has the data I need?
It uses Basic HTTP authentication

Categories

Resources