apex

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 7 Imported by: 0

README

Apex Codegen for Sending Email

Salesforce supports sending email from its system. You can do this programmatically or via the UI.

Some benefits of using Apex to send email with Salesforce:

  • You don't need to set up a separate MX record as Salesforce can send as your user's email address.
  • You can customize email by programmatically creating email
  • You can send email via Developer Workbench
  • Emails can be automatically attached to Salesforce Contacts
  • Emails do not count towards quota if you use TargetObjectId

This program allows you to auto-generate Apex code using Go. This project builds Apex code that can send HTML email via Salesforce Messaging.SingleEmailMessage and Messaging.sendEmail(emails). It has the following features:

  • Will accept simple subject and body templates
  • Can convert Markdown body to Salesforce HTML body
  • Can prioritize Contact.Id over Contact.Email for sending so messages can be associated with contact object
  • Automatically use setTargetObjectId vs. setToAddresses
  • Support Contact.Id or Contact.Email preference for sending to (a) attach to contact object and for (b) testing.

Example Useful SOQL

SELECT Id, Email, SenderEmail, FirstName, LastName, Name, UserType FROM User WHERE Email = 'myemail'

vyshakh.babji@ringcentral.com

Documentation

Index

Constants

View Source
const (
	To_             = "to_"
	Cc_             = "cc_"
	Bcc_            = "bcc_"
	TargetObjectID_ = "targetobjectid_"
	Sep             = ";"
)

Variables

This section is empty.

Functions

func ApexEmailsMapTemplate

func ApexEmailsMapTemplate(data map[string]map[string]string, emailSubjectTmpl, emailBodyTmpl, replyToEmail, senderDisplayName string) string

func ApexEmailsSliceTemplate

func ApexEmailsSliceTemplate(data []map[string]string, emailSubjectTmpl, emailBodyTmpl, replyToEmail, senderDisplayName string) string

func BuildApexEmail

func BuildApexEmail(req ApexEmailRequestOpts) string

func EscapeSingleQuote

func EscapeSingleQuote(s string) string

func MapStringMapStringStringToApex

func MapStringMapStringStringToApex(data map[string]map[string]string, initialize bool) string

func MapStringStringToApex

func MapStringStringToApex(data map[string]string, initialize bool) string

func MarkdownToApexEmailHTML added in v0.2.0

func MarkdownToApexEmailHTML(bytes []byte) string

func SliceMapStringStringToApex

func SliceMapStringStringToApex(data []map[string]string, initialize bool) string

func StreamApexEmailsMapTemplate

func StreamApexEmailsMapTemplate(qw422016 *qt422016.Writer, data map[string]map[string]string, emailSubjectTmpl, emailBodyTmpl, replyToEmail, senderDisplayName string)

func StreamApexEmailsSliceTemplate

func StreamApexEmailsSliceTemplate(qw422016 *qt422016.Writer, data []map[string]string, emailSubjectTmpl, emailBodyTmpl, replyToEmail, senderDisplayName string)

func StreamMapStringMapStringStringToApex

func StreamMapStringMapStringStringToApex(qw422016 *qt422016.Writer, data map[string]map[string]string, initialize bool)

func StreamMapStringStringToApex

func StreamMapStringStringToApex(qw422016 *qt422016.Writer, data map[string]string, initialize bool)

func StreamSliceMapStringStringToApex

func StreamSliceMapStringStringToApex(qw422016 *qt422016.Writer, data []map[string]string, initialize bool)

func StringToApexStringSimple

func StringToApexStringSimple(s string) string

func WriteApexEmailsMapTemplate

func WriteApexEmailsMapTemplate(qq422016 qtio422016.Writer, data map[string]map[string]string, emailSubjectTmpl, emailBodyTmpl, replyToEmail, senderDisplayName string)

func WriteApexEmailsSliceTemplate

func WriteApexEmailsSliceTemplate(qq422016 qtio422016.Writer, data []map[string]string, emailSubjectTmpl, emailBodyTmpl, replyToEmail, senderDisplayName string)

func WriteMapStringMapStringStringToApex

func WriteMapStringMapStringStringToApex(qq422016 qtio422016.Writer, data map[string]map[string]string, initialize bool)

func WriteMapStringStringToApex

func WriteMapStringStringToApex(qq422016 qtio422016.Writer, data map[string]string, initialize bool)

func WriteSliceMapStringStringToApex

func WriteSliceMapStringStringToApex(qq422016 qtio422016.Writer, data []map[string]string, initialize bool)

Types

type ApexEmailInfo

type ApexEmailInfo struct {
	To   []sobjects.Contact
	Cc   []sobjects.Contact
	Bcc  []sobjects.Contact
	Data map[string]string
}

func NewApexEmailInfo

func NewApexEmailInfo() ApexEmailInfo

func (*ApexEmailInfo) ToMap

func (email *ApexEmailInfo) ToMap(emailPriorityType EmailPriorityType) map[string]string

type ApexEmailRequestOpts

type ApexEmailRequestOpts struct {
	EmailInfos            []ApexEmailInfo
	SubjectTemplate       string
	BodyTemplate          string
	ReplyToEmail          string
	ReplyToName           string
	RecipientPriorityType EmailPriorityType
}

type EmailPriorityType

type EmailPriorityType int
const (
	// Setting ContactPriorityID will enable
	// Salesforce to associate the email with
	// the contact object and is generally
	// preferred/
	ContactPriorityID EmailPriorityType = iota
	ContactPriorityEmail
)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL