Email Service – ABSYZ https://absyz.com Salesforce Gold Consulting and Implementation Partner Fri, 27 Nov 2020 11:02:47 +0000 en-US hourly 1 https://absyz.com/wp-content/uploads/2020/06/cropped-favicon-1-1-32x32.png Email Service – ABSYZ https://absyz.com 32 32 Send ICS calendar invitations for Outlook meetings https://absyz.com/send-ics-calendar-invitations-for-outlook-meetings/ https://absyz.com/send-ics-calendar-invitations-for-outlook-meetings/#comments Wed, 18 Dec 2019 10:13:40 +0000 http://blogs.absyz.com/?p=10675

Here we are going to send the meeting invites from salesforce using ICS calendar to our outlook. In general ICS is the  iCalendar/.ics/.ical file and it is used to store the calendar information. Whenever you export anything a outlook, google, etc., calendar  it will automatically save as .ics file.

New and updated meetings are sent to participants using an email notification from particular person. This requires diligent effort from all participants to update their local calendars manually.  The idea is to automatically generate an ICS file with the meeting details and attach it to the notification email whenever an meeting is scheduled or rescheduled. This would allow participants to see the appointment into their calendars.

Let’s assume we have Meeting object in our Org with the following fields

 

  • Subject  – text field
  • Meeting Leader – email field
  • Objective of meeting – picklist field
  • start – Date/Time field
  • End – Date/Time field

Now we are trying to send the meeting invite after inserting or updating the record in salesforce. For that i was using the trigger whenever the record in inserted or updated.

Check the below code to send the ICS calendar invite..!!

 

[sourcecode language="java"]
 trigger meeting on Meeting__c (after Insert,after Update) {
    list<Meeting__c> meetList= new list<Meeting__c>();
    for(Meeting__c meet:trigger.new){
        meetList.add(meet);
    }
    AP_Meeting.sendInvite(meetList);
 }

[/sourcecode]

Below is the helper class..!!

 

[sourcecode language="java"]
public class AP_Meeting{
    public static void sendInvite(list<Meeting__c> meetingList) {
        list<string> UserEmailList = new list<string> ();
        string title;
        string meetingTitle;

        for(Meeting__c meet:meetingList){
            UserEmailList.add(meet.MeetingLeader__c);
            meetingTitle=meet.name+': '+meet.Subject__c;
            title=meet.Subject__c;
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(UserEmailList);
            mail.setPlainTextBody('This to inform that we have meeting related to particular problem');
            mail.setSubject(title);
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            attach.filename = 'meeting.ics';
            attach.ContentType = 'text/calendar; charset=utf-8; method=REQUEST'; //PUBLISH';//
            attach.inline = true;

            /***************************/
            attach.body = invite(UserEmailList, meet.MeetingLeader__c, 'Harish Lingam', meet.Subject__c, meet.start__c, meet.end__c, meet.createdDate, system.now(), meet.ObjectiveOfMeeting__c, meet.LastModifiedDate);
            mail.setFileAttachments(new Messaging.EmailFileAttachment[] {
                attach
                    });
            Messaging.SendEmailResult[] er = Messaging.sendEmail(new Messaging.Email[] {
                mail
                    });
        }
    }

    public static Blob invite(List<String> emailsList, String Organiser, string name, string subject, dateTime startDate, dateTime endDate, dateTime createdDate, string description, dateTime lastmodifiedDat) {
        String txtInvite = '';
        string startdateTime;
        string enddateTIme;
        string createdDateTime;
        string lastmodifiedDatTime;

        startdateTime = startDate.formatGMT('yyyyMMdd\'T\'HHmmss\'Z\'');
        enddateTIme = endDate.formatGMT('yyyyMMdd\'T\'HHmmss\'Z\'');
        createdDateTime = createdDate.formatGMT('yyyyMMdd\'T\'hhmmss\'Z\'');
        lastmodifiedDatTime = lastmodifiedDat.formatGMT('yyyyMMdd\'T\'hhmmss\'Z\'');

        txtInvite += 'BEGIN:VCALENDAR\n';
        txtInvite += 'PRODID:-//Microsoft Corporation//Outlook 16.0 MIMEDIR//EN\n';
        txtInvite += 'VERSION:2.0\n';
        txtInvite += 'CALSCALE:GREGORIAN\n';
        txtInvite += 'METHOD:REQUEST\n';
        txtInvite += 'REPLAY:ACCEPTED\n';
        txtInvite += 'BEGIN:VEVENT\n';
        txtInvite += 'ATTENDEE\n';
        txtInvite += 'CN=' + subject + '\n';
        for (String email: emailsList) {
            txtInvite += 'ATTENDEE:' + email + '\n';
        }
        txtInvite += 'X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n';
        txtInvite += 'X-WR-RELCALID:{0000002E-9CDF-9CE8-AD4C-66FC0A5A25F7}\n';
        txtInvite += 'CLASS:PUBLIC\n';
        txtInvite += 'CREATED:' + createdDateTime+'\n';
        txtInvite += 'DTEND:' + enddateTIme+'\n';
        txtInvite += 'DTSTART:' + startdateTime+'\n';
        txtInvite += 'LAST-MODIFIED:' + lastmodifiedDatTime+'\n';
        txtInvite += 'ORGANIZER;CN=' + name + ':mailto:' + Organiser + '\n';
        txtInvite += 'RSVP=TRUE\n';
        txtInvite += 'ROLE=REQ-PARTICIPANT\n';
        txtInvite += 'PARTSTAT=NEEDS-ACTION\n';
        txtInvite += 'CN=' + subject + ':mailto:' + Organiser + '\n';
        txtInvite += 'LOCATION:Skype\n';
        txtInvite += 'PRIORITY:5\n';
        txtInvite += 'SEQUENCE:0\n';
        txtInvite += 'SUMMARY:\n';
        txtInvite += 'STATUS:NEEDS-ACTION\n';
        txtInvite += 'LANGUAGE=en-us:\n';
        txtInvite += 'TRANSP:OPAQUE\n';
        txtInvite += 'UID:4036587160834EA4AE7848CBD028D1D200000000000000000000000000000000\n';
        txtInvite += 'X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD><META NAME="Generator" CONTENT="MS Exchange Server version 08.00.0681.000"><TITLE></TITLE></HEAD><BODY><!-- Converted from text/plain format --></BODY></HTML>\n';
        txtInvite += 'X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n';
        txtInvite += 'X-MICROSOFT-CDO-IMPORTANCE:1\n';
        txtInvite += 'BEGIN:VALARM\n';
        txtInvite += 'TRIGGER:-PT15M\n';
        txtInvite += 'ACTION:DISPLAY\n';
        txtInvite += 'STATUS:CONFIRMED\n';
        txtInvite += 'DESCRIPTION:Reminder\n';
        txtInvite += 'END:VALARM\n';
        txtInvite += 'END:VEVENT\n';
        txtInvite += 'END:VCALENDAR';
        return Blob.valueOf(txtInvite);
     }
 }
[/sourcecode]

Now lets create a record in the org.  fill the information needed…!!

Now it will directly create a meeting calendar invite in outlook with the details provided. Make sure the all the details filled whatever it is we have used in the code.

 

m5-e1576651434409.png

 

m2

Now we can check calendar for invite.

Now if you want to reschedule the meeting, for that we need to update the record, by updating Start and End time. Now we have rescheduled the meeting to the next day and now the calendar is updated,

 

m6.png

So now you will receive new email with the updated calendar info. Now check the calendar for the updated information.

 

m4

Finally you can add the email template in what ever format you need it, you can also send to the bunch of the people by adding them to the public groups.

 

]]>
https://absyz.com/send-ics-calendar-invitations-for-outlook-meetings/feed/ 1
Bulk Import Email from Gmail to Salesforce https://absyz.com/bulk-import-email-from-gmail-to-salesforce/ https://absyz.com/bulk-import-email-from-gmail-to-salesforce/#comments Thu, 06 Jun 2019 09:20:12 +0000 http://blogs.absyz.com/2019/06/06/bulk-import-email-from-gmail-to-salesforce/

Use Case : Customer needs to import all emails along with attachment from their Gmail account into their Salesforce org.

Problem: Currently, there is no way to mass-import emails within the Salesforce User Interface

Resolution: We are going to export email into MBOX format.Then using python script we will generate CSV and using data loader we will insert email into Email Message object in salesforce.

Prerequisite:

1.Python 3.X should be installed in Local system.

2.Data loader.

Step 1:

 

  • Go to https://takeout.google.com/
  • Sign In to Gmail Account to extract Email.
  • Check Mail and select the labels to extract all the related Emails.
  • Screenshot 2019-06-06 at 12.54.35 PM.png

    Click create Archive to download MBOX file.

    Screenshot 2019-06-06 at 12.56.27 PM.png
Step 2:

 

  • Place the MBOX file and Python script in a same folder.
  • /*** Rename the MBOX file to Sample.mbox***/.
  • Get python script from this Github link Python Script
  • Screenshot 2019-06-06 at 1.04.11 PM.png

    Run the Python script using Terminal or IDLE.

  • we will get 2 CSV files ( emailMessage.csv, attachment.csv ) as output along with all the attachment files.
  • Message-Id column in  emailMessage.csv will act as unique id for each message.
  • If there is any attachment, we can find in  attachment.csv file. Each attachment will have message Id to signify this attachment belong to which email.

Point to Note :

In attachment.csv file, Body column prepend the current file path with file name(already present).

 

Screenshot 2019-06-06 at 2.27.11 PM.png

eg :

Step 3:

 

  • Create Custom Fields in Email Message object to store Message-Id.
  • Insert emailMessage.csv using Data loader into salesforce.
  •  In success.csv file we can get Message-Id and corresponding Salesforce record Id.
  • In attachment.csv file get the parent id based on Message-Id using VLOOKUP.
  • Insert attachment.csv using data loader.
  • we can find Attachment under Email Message related List.

 

]]>
https://absyz.com/bulk-import-email-from-gmail-to-salesforce/feed/ 2
SENDING REPORTS TO EMAIL AS AN ATTACHMENT https://absyz.com/sending-reports-to-email-as-an-attachment/ https://absyz.com/sending-reports-to-email-as-an-attachment/#comments Thu, 27 Sep 2018 06:01:34 +0000 http://blogs.absyz.com/?p=9382

We all know how to create reports and dashboards, but the challenge arises when we need to send reports to email as an excel attachment. Salesforce doesn’t provide us with standard inbuilt functionality to do so. I too faced the same challenge and built a solution for this. We have to follow certain steps to achieve this approach.

  1. Create a report
  2. Create a Visualforce Component
  3. Create a Visualforce Email Template

 

1.Create a report

Creating a report or we can take any existing report which is already present in the Org. And make sure that the report preview format is the tabular format.

2. Create a Visualforce Component

Next, we need to create a visualforce component to get the report data and to display as a report. Here we are getting the report Id from the Email Template.

Visualforce Component: ReportsToEmail

[sourcecode language=”java”]
<apex:component controller=”ReportsToEmailController” access=”global”>
<apex:attribute name=”ReportId” description=”Report ID” type=”Id” assignTo=”{!rptId}”/>
<apex:outputPanel>
<table style=”width: 100%;”>
<thead>
<apex:repeat value=”{!ReportResult.reportMetadata.detailColumns}” var=”colName”>

<!– reportMetadata is a class where it contains metadata of a report.
DetailColumns is a method of ReportMetadata class, it returns the API names (Columns Names)
for the fields that contain detailed data–>

<th><apex:outputText value=”{!ReportResult.reportExtendedMetadata.detailColumnInfo[colName].label}”/></th>

<!– reportExtendedMetadata is class where it contains Report extended metadata and
it provides data type and label information.
detailColumnInfo is a method of reportExtendedMetadata class, it returns map of columns names
and its label to Display as Header –>

</apex:repeat>
</thead>
<tbody>
<apex:repeat value=”{!ReportResult.factMap[‘T!T’].rows}” var=”row” rows=”999″>
<!– Here we will get entire data of each row and T refers to the Row –>
<tr> <apex:repeat value=”{!row.dataCells}” var=”cell”>
<!– Here we will get data of each cell and displayed –>
<td><apex:outputText value=”{!cell.label}”/></td>
</apex:repeat> </tr>
</apex:repeat>
</tbody>
</table>
</apex:outputPanel>
</apex:component>
[/sourcecode]

Apex Controller: ReportsToEmailController

[sourcecode language=”java”]
public class ReportsToEmailController {
public Id rptId { get; set; } // Here we will get the report Id from the VF Component
private transient Reports.ReportResults results; // It will hold the entire data of a report

/*********************
// Method Name : getReportResult
// Description : Here we will get the data of a report and send to the VF Component
/********************/

public Reports.ReportResults getReportResult() {
// Here it will run the report with that report ID and adding the report data into results
results = Reports.ReportManager.runReport(rptId, true);
return results;
}
}
[/sourcecode]

3. Create a Visualforce Email Template

EmailTemplate

After creating that we need to edit the template and add the visualforce component as an attachment.

[sourcecode language=”java”]
<messaging:emailTemplate subject=”Report” recipientType=”User” >
<messaging:plainTextEmailBody >
Hi {!recipient.FirstName}
Please find the below attachments.

</messaging:plainTextEmailBody>
<messaging:attachment filename=”Account Report.xls”>
<!– Here we can add multiple Reports –>
<c:ReportsToEmail ReportId=”xxxxxxxxxxxxxxxxxxxx”/>
<c:ReportsToEmail ReportId=”xxxxxxxxxxxxxxxxxxxx”/>
</messaging:attachment>
</messaging:emailTemplate>
[/sourcecode]

 <c:ReportsToEmail ReportId=”xxxxxxxxxxxxxxxxxx”/> ” Here I have called the VF component and we need to give the Report ID. In filename I am giving the name of the file and the type of the attachment(.xls), it automatically attaches the file to an email.

This Email Template can be used in Email Alerts or in apex class and from there you can send the reports to Email.

Here I am using a checkbox field to send email, using workflow whenever this checkbox field is true I am sending the reports to the email using email alert and then I am unchecking the checkbox using field update.

]]>
https://absyz.com/sending-reports-to-email-as-an-attachment/feed/ 5
Integrating Salesforce and Microsoft Outlook by using Lightning for Outlook https://absyz.com/integrating-salesforce-and-microsoft-outlook-by-using-lightning-for-outlook/ https://absyz.com/integrating-salesforce-and-microsoft-outlook-by-using-lightning-for-outlook/#respond Tue, 16 Jan 2018 06:23:58 +0000 https://teamforcesite.wordpress.com/?p=8362

Effective Time Management is important to achieve success during the Sales process. But there seems to be the problem faced by Sales rep daily while sending and replying Email. Customer Relationship Management (CRM) and email application, meantime as they are separate, sales rep have needed to move between them.

This blog will help you to integrate Outlook and Salesforce with the help of Lightning for Outlook. When you integrate Outlook and Salesforce, this will invest less energy entering information and flipping between the two frameworks. This enables the Sales team to increase their Sales. This likewise tracks imperative email discussions pertinent to Salesforce records. This will help to:

  • Dispense with an opportunity to spend on copy information section into two frameworks.
  • Access imperative Outlook Email messages and significant Salesforce records in a single place.

Lightning for Outlook has been totally updated to get the Lightning User Experience. As a user looks through their inbox, the cutting edge and natural UX makes it simple to see and connect with applicable experiences and applications. Also, the new search tool makes it simple to scan for Salesforce records inside Outlook.

Lightning for Outlook System Requirements

To integrate Outlook and Salesforce following are the requirements:

Email server Either:

  • Exchange 2016 or 2013 on-premise
  • Exchange Online with Office 365
Email application Either:

  • Outlook Web App
  • Microsoft Outlook® 2016 or 2013 on Windows PC, most recent stable version recommended
  • Microsoft Outlook for Mac 2016
Browser Any of these browsers that allow cookies from Salesforce on Windows or Mac operating systems.

  • Google Chrome™, most recent stable version
  • Mozilla® Firefox®, most recent stable version
  • Apple® Safari®, most recent stable version
  • Microsoft Internet Explorer® 11 (Windows only)
  • Microsoft Edge, most recent stable version (Windows only)

Step 1: Set Up Lightning for Outlook in Salesforce

From Salesforce setup, enter Lightning for Outlook in the Quick find Box, then select Lightning for Outlook (1). Enable Lightning for Outlook (2). Select your working environment Production/Sandbox (3).

3

Step 2: Set Up Lightning for Outlook in the Microsoft Outlook

First, you need to add Lightning for Outlook extension to Microsoft Outlook from the store (1). Enter Lightning for Outlook in the search box (2) and Turn it On to enable it for Microsoft Outlook(3).

1

2. Now open your Outlook mailbox, click in an email (1). Next, click the Salesforce Cloud View Button (2). Finally, log in to your Salesforce Account by clicking on Log into Salesforce button (3).

2

3. To Login to your Salesforce Account enter your Salesforce credentials.

5

4. Enter Verification Code to verify your identity. Also, don’t miss to check the checkbox.

7

5. Click on Confirm.

4

6. Congratulations! Now your Outlook inbox is connected to your Salesforce account.

6

  • Create records:

Open your outlook inbox and click on email record and then Salesforce cloud icon. It will show the Salesforce record present related to that email in side panel.

8

To create record related to email click on 11 button. CREATE drop-down list will appear. For example, you received Opportunity from email then you click on the email and select New Opportunity from CREATE drop-down list.

10

To open the Salesforce record from browser click on12icon.

  • Relating Emails

Click on the up arrow next to a record to relate that email with Salesforce record. After clicking, an alert will appear and up arrow turn into a checkmark. To remove related email uncheck the checkbox.

9

You can relate email to multiple Contacts. But you cannot relate the same Email to different types of records like 1 with Account and the same with Opportunity.

14

Emailed Attachments also can be added to Salesforce. Make sure that checkbox has been checked before including the attachment. You will get Alert after relating it to record.

15

  • Searching from Salesforce

You can search Salesforce record by entering search field inside search area. This will show TOP RESULTS like Account, Opportunity, Contact and Lead only. If you want to see results for other objects click on a MORE drop-down button.

16

Conclusion:

Lightning for Outlook helps your sales reps to spend less time in switching between Salesforce and Microsoft Outlook & searching the Salesforce records within Outlook.

Resources:

Setup Lightning for Outlook in Microsoft Outlook

]]>
https://absyz.com/integrating-salesforce-and-microsoft-outlook-by-using-lightning-for-outlook/feed/ 0
What is Enhanced Email ? https://absyz.com/what-is-enhanced-email/ https://absyz.com/what-is-enhanced-email/#comments Fri, 06 Jan 2017 13:39:06 +0000 https://teamforcesite.wordpress.com/?p=3729

screen-shot-2016-12-08-at-10-51-14-am

Enhanced Email was released in Summer ’16 to open up email features that were previously only available in Email-to-Case (E2C).

Release Note

Enhanced Email is automatically enabled for most organizations except those that use Email-to-Case. You can check this at Setup-> Enhanced Email

Let’s understand basic email-task first. In Salesforce, if you do not have E2C and Enhanced Email enabled, emails sent out are stored as tasks. This applies to all objects. Emails sent out from Case records begin to behave differently when you enable E2C.

Once you enable and set up E2C, 2 functionalities are introduced in emails related to Case records:

  1. An email service is created in Salesforce, which would receive emails from external sources and associate to Cases/Create new Cases.
  2. The emails that are sent out from Case records are shown as tasks in the Activity History related list, but open as EmailMessage records. The EmailMessage records have a prefix ‘02s’.

Enhanced Email in summary, is the 2nd point of Email-to-Case functionality applied to all objects on your Org.

One clear advantage of having the EmailMessage object is the ability to customize the object itself. If you go to Setup -> Email -> Email Message, you’ll see that you have the option of adding custom fields, triggers, buttons, validation rules e.t.c. to the EmailMessage object.

The ability to add custom fields to the EmailMessage records allows you to customize the object according to your own scenario. For e.g. suppose the first email that is sent to a customer needs to be marked. A simple checkbox and some trigger logic on Email Message object could achieve it.

Another thing to notice is that even if you create and add custom fields to the  Email page layout, it’s visible only after the email is sent. When you send a new email ( analogous to creating a new record), only a certain set of fields are available in the UI. Once the email is sent and the email record is saved, you’ll be able to see your custom fields in the layout and edit them too. Standard fields aren’t editable.

After enabling Enhanced Email, all your objects have the EmailMessage object exposed to them and all Outbound Emails are stored as EmailMessage records. Each one of your EmailMessage records also have corresponding task records which can be found by querying the ActivityId field.

Other advantages of having Enhanced Email:

  1. Validation rules for Email messages.
  2. Trigger logic for any complex processing
  3. Page layouts for profiles.
  4. Custom buttons, links on the page.

All these features were previously only available when Email-to-Case was enabled and was only available for Case emails. With Enhanced email, this becomes available to all objects.

Extra :

Check out the EmailMessageRelation object. It stores the relationship of the Contacts, Leads or Users who were Sender/Recipient in an EmailMessage.

]]>
https://absyz.com/what-is-enhanced-email/feed/ 3
Creating Google Calendar Events from Salesforce Without Integration https://absyz.com/creating-google-calender-events-from-salesforce-without-integartion/ https://absyz.com/creating-google-calender-events-from-salesforce-without-integartion/#comments Wed, 18 May 2016 06:23:11 +0000 https://teamforcesite.wordpress.com/?p=1272

Hi All,

This blog helps you to create Google calendar events from Salesforce without any integration. Why to create Google Calendar events?

For Example: In your organization HR is sending emails to the interviewers to take interviews. The interviewers may forget on the interview day for taking the interview on time. So to overcome these type of problem we can create google calendar events on the interviewer google calendar so the interviewer will get the remainder of interview on time.

To create google calendar events from Salesforce there are mainly two ways the first process is using integration but using the integration we need to know there google username and password or using Oath Authentication and this process is pretty hard. So the second process is using Google Email Markup and create google calendar events.

What is Google Email Markup?  Email markup uses structured data in emails to work. Inbox and Gmail support both JSON-LD and Microdata and you can use either of them to markup information in email. This lets Google understand the fields and provide the user with relevant search results, actions like creating google calendar events.

To know more about Email Markup visit this link: https://developers.google.com/gmail/markup/getting-started#your_first_markup

Creation of Email Markup:

First Create an HTML email message. HTML Email message example is given below.

[sourcecode language=”java”]
<html>
<body>
Dear John, You have an interview Scheduled for First Round in ABC Company.

INTERVIEW DETAILS
Name: John Max
Event: 1st Round Interview
When: May 6th 2016 8:30am PST
Venue: ATT Park 24, Willie Mays Plaza, San Francisco, CA 94107 US
</body>
</html>

[/sourcecode]

 

This HTML email needs to be converted to email markup. To convert HTML email to markup there is a tool named ‘Structured data markup helper‘. To open that tool click on this link: https://www.google.com/webmasters/markup-helper/u/0/?email=true

The image of Structured data markup helper is given below.

Structured Mark Up

Paste the above HTML code in the text area ‘Paste HTML here’. Select any data type of markup here i am selecting ‘Event Reservations’ from the radio buttons. Click on ‘Start Tagging’ button on the bottom section of text area. The page will be navigated to next stage.

Tag data page

The next page will be displayed on the above image. Here on the left side of the image is the HTML email message and on the right side of the image is event parameters. So we need to match the event parameters to the email message. Double click on any word in HTML email message the a picklist will be opened there we can select any event parameter and map the parameter to that word.

Untitled

Here the ‘Interview Scheduled for First Round’ is mapped with event name. So we need to map HTML Email message with the parameters once email message is mapped with the parameters then click on ‘Create HTML’ button on the top right corner then page will be navigated to third stage.

Third Page

In the right side of the above image indicates the email markup of the HTML email message. To validate the Email Markup there is a tool available in the market. To open this tool click on this link: https://www.google.com/webmasters/markup-tester/u/0/

Paste the HTML Email Message and Markup in the text area and click on ‘Validate’ button if you get ‘No errors detected’ then your markup is good to go.

emailmarker

Paste the HTML Email Message and Markup in the Custom Email Template in Salesforce.

Create Custom Email Template:

To create custom email template click on Setup-> Communication Templates-> Email Templates-> Click on New Template-> select Custom (without using letterhead) and click on next paste the HTML and email markup. Click on Save.

[sourcecode language=”java”]
<html>
<script type=”application/ld+json”
{
“@context”: “http://schema.org”,
“@type”: “Event”,
“name”: “1st Round Interview Scheduled”,
“startDate”: “2016-05-18T15:30:00Z”,
“endDate”: “2016-05-18T16:30:00Z”,
“location”: {
“type”: “Place”,
“address”: {
“@type”: “PostalAddress”,
“name”: “John Max”,
“streetAddress”: “24 Willie Mays Plaza”,
“addressLocality”: “San Francisco”,
“addressRegion”: “CA”,
“postalCode”: “94107”,
“addressCountry”: “USA”
}
},
“potentialAction”: [
{
“@type”: “RsvpAction”,
“handler”: {
“@type”: “HttpActionHandler”,
“url”: “https://ap2.salesforce.com/home/rsvp?eventId=123&value=yes”
},
“attendance”: “http://schema.org/RsvpAttendance/Yes”
},
{
“@type”: “RsvpAction”,
“handler”: {
“@type”:”HttpActionHandler”,
“url”: “https://ap2.salesforce.com/home/rsvp?eventId=123&value=no”
},
“attendance”: “http://schema.org/RsvpAttendance/No”
},
{
“@type”: “RsvpAction”,
“handler”: {
“@type”: “HttpActionHandler”,
“url”: “https://ap2.salesforce.com/home/rsvp?eventId=123&value=maybe”
},
“attendance”: “http://schema.org/RsvpAttendance/Maybe”
}
]
}
</script>

<body>
Dear John, You have an interview Scheduled for First Round in ABC Company.

INTERVIEW DETAILS
Name: John Max
Event: 1st Round Interview
When: May 6th 2016 8:30am PST
Venue: ATT Park 24, Willie Mays Plaza, San Francisco, CA 94107 US
</body>
</html>

[/sourcecode]

This email template will work if our Salesforce org is registered in google. For registering with google use this link: https://docs.google.com/a/cloudalyze.com/forms/d/1PA-vjjk3yJF7MLPOVKbIz3MBfhyma2obS8NIZ0JYx8I/viewform?pli=1

But for testing the email markup we can use a tool. The link for the tool is: http://gmail-actions.appspot.com/

tester

Note:

The logged in and sending email must be the same email address.

On clicking ‘Send Email’ button then an email will be send to your sending email address.

The Email message will be looking like this in the below image.

email.png

On clicking Yes button a google calendar event will be created. We can create google calendar events from Salesforce without using any integration.

Please post your comments or inputs if you feel this blog is helpful.

]]>
https://absyz.com/creating-google-calender-events-from-salesforce-without-integartion/feed/ 1
Email Services in Salesforce with a simple example https://absyz.com/email-services-in-salesforce-with-simple-example/ https://absyz.com/email-services-in-salesforce-with-simple-example/#respond Tue, 22 Mar 2016 11:26:28 +0000 https://teamforcesite.wordpress.com/?p=566

Email Services is a feature of salesforce.com where, the user can assign an Apex Class that implements the Messaging.InboundEmailHandler interface to a configuration which allows you to process the email contents, headers and attachments. Using this Information, you can cater a variety of requirements . Listing few, create a new contact if one does not exists with that email address, receive job applications and attached the person’s resume to their record.

Email services are basically an option to a developer to develop a functionality , where an email can be received at a particular address and some operations can happen on the data retrieved from the email. These operations are done by the Apex Code, thus giving us a spectrum of options that fulfils requirements.

Explaining few,

A track of contacts can be kept , once the email is received the contacts are checked for the email address and if not a new contact is created and the attachments in the mail can be added to the new contact record.

In a Human resources management system, All job posting can have a email to it . All the job applications can be received via email and the subject can become the Job title the applicant is applying to. The email service automatically receives the email and creates a job application record using the subject of the email to categorise between job applied for and the resumes can be attached to the job application record as attachments.

Now to start using them,

You can Navigate to Salesforce Email Services using this path : Setup -> Develop -> Email Services,

OR just type Email services in the Quick Find Box.

Click the “New Email Service” button to get started and fill out the form.

The Form has a number of Options, Including Name, Apex Class Etc. Some Options are very handy, “Enable Error Routing” will send the inbound email to an alternative email address when the processing fails. You can can also specify email address to accept mail from.

Note : Make Sure you create a Basic Class that implements the Messaging.InboundEmailHandler interface that can be assign as the class here.

After you save the new email service, you will need to scroll down to the bottom of the page and create a new email address for the service. An email service can have multiple email addresses and therefore process the same message differently for each address. When you create a new email service address you specify the “Context User” and “Accept Email From”. The email service uses the permissions of the Context User when processing the inbound message. So you could, for example, have the same email service that accepts email from US accounts and processes them with a US context user. After the form is submitted the Platform will create a Unique Email Address, To which the email has to be sent. For Example,

test@h-146i8zqbmxebmwfhxj8mdwp1kt96y38ko1b2a9x5rsxea0w8mh.9-10wvleae.ap1.apex.salesforce.com .

Now that we are done with configuring the Email Services, We can move to write the Apex Class as per Requirements.

Scenario :  Create a Contact using the Information in the email and add attachments.

[sourcecode language=”java”]
global class EmailService implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
list&amp;amp;lt;Attachment&amp;amp;gt;att = new list&amp;amp;lt;Attachment&amp;amp;gt;();
Contact con = new contact();
if(email.fromname!=null||email.fromname!=”){
con.FirstName = email.fromname.substring(0, email.fromname.indexOf(‘ ‘));
con.LastName = email.fromname.substring(email.fromname.indexOf(‘ ‘));
}
con.email = envelope.fromaddress;
if(email.plaintextbody!=null||email.plaintextbody!=”)
con.description = email.plaintextbody;
if(email.subject!=null||email.subject!=”)
con.title = email.subject;
insert con;

if (email.binaryAttachments != null &amp;amp;amp;&amp;amp;amp; email.binaryAttachments.size() &amp;amp;gt; 0) {
for (integer i = 0;i&amp;amp;lt;email.binaryAttachments.size();i++) {
Attachment attachment = new Attachment();
attachment.ParentId = con.Id;
attachment.Name = email.binaryAttachments[i].filename;
attachment.Body = email.binaryAttachments[i].body;
att.add(attachment);
}
insert att;
}

if (email.textAttachments != null &amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp; email.textAttachments.size() &amp;amp;amp;amp;amp;gt; 0) {
for (integer i = 0; i &amp;amp;amp;amp;amp;lt; email.textAttachments.size(); i++) {
Attachment attachment = new Attachment();
attachment.ParentId = con.Id;
attachment.Name = email.textAttachments[i].filename;
attachment.Body = blob.valueOf(email.textAttachments[i].body);
att.add(attachment);
}
insert att;
}
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
return result;
}
}
[/sourcecode]

 

Similarly you can have any sort of code in
the apex class, Depends solely on what the 
requirement is. 
Basically the lines of code can use the 
information available and perform some 
operations based on the requirements. 

Happy coding!!!
]]>
https://absyz.com/email-services-in-salesforce-with-simple-example/feed/ 0