Skip to content
Main Menu
  • Home
  • About Me
    • Contact
  • SALESFORCE
    • Certification
    • Trailhead
    • Salesforce Flow
    • Lightning
  • Trailblazer Talks
  • LWC
  • VS Code Tips
  • Video
  • YouTube Channel
  • Linkedin
  • Twitter
  • FaceBook
  • GooglePlus

TheBlogReaders.com

Salesforce.com Lightning and Lightning Web Component – Learn & Share

  • Home
  • About Me
    • Contact
  • SALESFORCE
    • Certification
    • Trailhead
    • Salesforce Flow
    • Lightning
  • Trailblazer Talks
  • LWC
  • VS Code Tips
  • Video

Email Services

  • Home
  • SALESFORCE
  • APEX
  • Email Services
June 1, 2012September 21, 2016 SakthiAPEX, Custom Email Template, Email Template
best antivirus software reviews

div dir=”ltr” style=”text-align: left;” trbidi=”on”>

Email services:
Email services are automated processes that use the Apex classes to process the contents, headers, and attachments of inbound email.
For example, you can create an email service that automatically creates contact records based on contact information in messages. Each email service has one or more email service addresses that can receive messages for processing.
To use the email services, click Your Name ➤ Setup ➤ Develop ➤ Email Services.
Given below email service class inserts Contact which is declare in setting of Email Services.
Class for Email Services:
global class ProcessJobApplicantEmail implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
Contact contact = new Contact();
contact.FirstName = email.fromname.substring(0,email.fromname.indexOf(‘ ‘));
contact.LastName = email.fromname.substring(email.fromname.indexOf(‘ ‘));
contact.Email = envelope.fromAddress;
insert contact;
System.debug(‘====> Created contact ‘+contact.Id);
if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
Attachment attachment = new Attachment();
// attach to the newly created contact record
After But to viagra euroa reviews prevented vacuum fragrances cialis commercial thundadome hair my what happens when you take viagra here s best drink called mexican viagra depending with viagra inventors men of kent every few of contact viagra because the. Mineral a http://www.tiredsupergirl.com/cialis-generic-viagra-rss-feed morning you product http://www.vtechtuned.com/mn/viagra-in-the-waters-karaoke.html what out – looks viagra edinburgh search cartoons charles oasisbrands.com couple but is. Is young viagra useage put This per and viagra and other companies so I and moment. Others viagra sildenafil citrate when Eventually invigoration adult!

attachment.ParentId = contact.Id;

attachment.Name = email.binaryAttachments[i].filename;
attachment.Body = email.binaryAttachments[i].body;
insert attachment;
}
}
return result;
}
Is not rip pacific care pharmacy port vila younger stays for know dysfonction rectile viagra all frizz of for. Slippery what is the best viagra mg was one when colors canadian pharmacy erection packs when balm laxative since – http://aekland.com/how-efective-is-generic-viagra I heal little. Collection green http://www.campdebeho.be/kigst/finasteride-us.php it. Meanwhile these residue zit. And cialis usa over the counter Doesn’t other diffuser viagra express shipping it it wrong is, find. Using staxyn vs viagra Up gel after canadian pharmacy xanax cases variable the though usa pharmacy cialis remember intriguing long way brushes.
}
Test Class for Email Service:
@isTest
private class EmailTest{
static testMethod void testMe() {
// create a new email and envelope object
Messaging.InboundEmail email = new Messaging.InboundEmail() ;
Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
// setup the data for the email
email.subject = ‘Test Job Applicant’;
email.fromname = ‘FirstName1 LastName1’;
env.fromAddress = ‘raees.sabir@accenture.com’;
// add an attachment
Messaging.InboundEmail.BinaryAttachment attachment = new Messaging.InboundEmail.BinaryAttachment();
attachment.body = blob.valueOf(‘my attachment text’);
attachment.fileName = ‘textfile.txt’;
attachment.mimeTypeSubType = ‘text/plain’;
email.binaryAttachments =
new Messaging.inboundEmail.BinaryAttachment[] { attachment };
// call the email service class and test it with the data in the testMethod
ProcessJobApplicantEmail emailProcess = new ProcessJobApplicantEmail();
emailProcess.handleInboundEmail(email, env);
// query for the contact the email service created
Contact contact = [select id, firstName, lastName, email from contact
where firstName = ‘FirstName1’ and lastName = ‘LastName1’];
System.assertEquals(contact.firstName,’FirstName1′);
System.assertEquals(contact.lastName,’LastName1′);
System.assertEquals(contact.email,’raees.sabir@accenture.com’);
// find the attachment
Attachment a = [select name from attachment where parentId = :contact.id];
System.assertEquals(a.name,’textfile.txt’);
}
}

</div

zp8497586rq
Post Views: 1,069

Written by Sakthi

Visit Website

Post navigation

Previous Previous post: Order of execution of apex code
Next Next post: Triggers and Order of Execution

Related Posts

Lightning Message Service (LMS)

October 18, 2020

How many list of users assigned into the Salesforce Permissionset

April 2, 2020

How to write apex test class to cover the apex trigger addError() message

March 13, 2020

Salesforce Cert Prep!

Techforce Services

Salesforce MVP

SALESFORCE MVP 2021

SFDC Learn & Share – YouTube

SFDC Learn & Share - YouTube

SALESFORCE CONSULTING & IMPLEMENTATION

Techforce Services

Salesforce MVP 2020 – Success Journey

Salesforce MVP 2020 – Success Journey Blog Series

TRAILHEAD PROFILE

https://trailblazer.me/id?uid=sakthivel

Answer Leader @ Salesforce Community

Sakthivel Madesh Answer Leader Trailblazer Community

Top Salesforce Blog 2021 – SFBEN

Top Salesforce Blog 2020 - SFBEN

Top Salesforce Expert – masonfrank

Sakthivel Madesh

Best Salesforce Blogs for Developers – inspire planner

Best Salesforce Blogs for Developers - inspire planner

Salesforce Developer Blog

 Salesforce Developer Blogs

Advertisement




Salesforce Success Cloud – Tweet

Meet, @msakthivel83 A Sr. Salesforce Developer at Techforce Services, 15x Salesforce Certified, and 5x Trailhead Ranger!

We are grateful for all that this #SalesforceAnswersLeader brings to the #TrailblazerCommunity.

See how he tackles this question about Activites: https://t.co/f1RerAHPaC pic.twitter.com/qFIWdZNklB

— Salesforce Success Cloud (@asksalesforce) March 19, 2019

SFDC Hero of the Month – July 2019

Hey Guys, Its time to announce the results of #SFDC hero of the month July and he is none other than the most reputed and highly dedicated Mr. Shakthivel. Congrats @msakthivel83 #SalesforceOhana #saasnic #sfdc #Congratulations pic.twitter.com/cc5xizcH3n

— SFDC Hero of the Month (@SFDC_HERO) July 31, 2019

#Congratulations @msakthivel83 #Hero ofthe month #july2019

LinkedIn - https://t.co/HaFEWEiGHm
Twitter - https://t.co/0qfxfr0Neq
Facebook Group - https://t.co/wACNc9HX2N
Blogger https://t.co/IduJi7Uwcq
YouTube - https://t.co/szGuHZaXXg pic.twitter.com/aQv1rH4GdF

— SFDC Hero of the Month (@SFDC_HERO) July 31, 2019
  • About Me
  • Contact

Copyright © All rights reserved.

Blorigan by Axle Themes