Email Service

Email Service Management can be used by the app to configure host email account and send emails to one or multiple recipients. Developers can create and manage templates for sending mails as well. This module is also used in launching Email Campaigns through App42 Marketing Automation.

In order to use the various functions available in a specific API, the developer has to initialize with App42API by passing the apiKey and the secretKey which will become available after the app creation from AppHQ dashboard.

Required Parameters

apiKey - The Application key given when the application was created.
secretKey - The secret key corresponding to the application key given when the application was created.

After initialization, the developer will have to call the buildXXXService method on App42API to get the instance of the particular API that they wish to build. For example, to build an instance of EmailService, buildEmailService() method needs to be called.

EmailService emailService = App42API.buildEmailService();

EmailService emailService = App42API.BuildEmailService();

EmailService *emailService = [App42API buildEmailService];

let emailService = App42API.buildEmailService() as? EmailService

EmailService emailService = App42API.buildEmailService();

EmailService emailService = App42API.BuildEmailService();

var emailService = new App42Email();

local emailService = App42API:buildEmailService()

EmailService *emailService = App42API::BuildEmailService();

EmailService emailService = App42API.BuildEmailService();

$emailService = App42API::buildEmailService();

EmailService *emailService = App42API::BuildEmailService();

email_service = api.build_email_service()

var emailService:EmailService = App42API.buildEmailService();

Coming Soon

EmailService emailService = App42API.buildEmailService();

Create Email Configuration

Create Email Configuration using which in future the developer can send mails.

Required Parameters

emailHost - Email Host to be used for sending mails.
emailPort - Email Port to be used for sending mails.
emailId - Email ID to be used for sending mails.
password - Email Password to be used for sending mails.
isSSL - Should be sent using SSL or not.

local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local emailService = App42API:buildEmailService()
emailService:getEmailConfigurations(App42CallBack)
function App42CallBack:onSuccess(object));
if table.getn(object:getConfigList()) >1 then
for m=1,table.getn(object:getConfigList()) do
print("emailId is "..object:getConfigList()[m]:getEmailId())
print("Host is " .. object:getConfigList()[m]:getHost());
print("Port is "..object:getConfigList()[m]:getPort());
print(object:getConfigList()[m]:getSsl());
end
else
print("emailId is "..object:getConfigList():getEmailId())
print("Host is " ..object:getConfigList():getHost());
print("Port is "..object:getConfigList():getPort());
print(object:getConfigList():getSsl());
end
end
function App42CallBack:onException(object)
print("Message is "..object:getAppErrorCode());
print("Message is "..object:getHttpErrorCode());
print("Message is "..object:getMessage());
print("Message is "..object:getDetails());
end

Send the email to user to whom you want to send, email will be sent from configuration that you have created.

Required Parameters

senderEmailId - The Email ID using which the mail has to be sent.
sendTo - The email IDs to which the email has to be sent. Email can be sent to multiple email IDs. Multiple email ids can be passed using comma as the separator. For example support@shephertz.com, info@shephertz.com.
sendSubject - Subject of the Email which to be sent.
sendMsg - Email body which has to be sent.
emailMime - MIME Type to be used for sending mail. EmailMime available options are PLAIN_TEXT_MIME_TYPE or HTML_TEXT_MIME_TYPE.

Send the email to user to whom you want to send, email will be sent from configuration that you have created.

Required Parameters

senderEmailId - The Email ID using which the mail has to be sent.
sendTo - The email IDs to which the email has to be sent. Email can be sent to multiple email IDs. Multiple email IDs can be passed using comma as the separator. For example support@shephertz.com, info@shephertz.com.
sendSubject - Subject of the Email which to be sent.
sendMsg - Email body which has to be sent.
emailMime - MIME Type to be used for sending mail. EmailMime available options are PLAIN_TEXT_MIME_TYPE or HTML_TEXT_MIME_TYPE.

The functions available under Email API can throw some exceptions in abnormal conditions. For example if a developer is removing the email configuration that does not exist, the function will throw the App42Exception (as shown below) with the message as “Not Found” and the appErrorCode as “2303” and the details as “Email with the id ‘nick@gmail.com’ does not exist”.