Module: Infusionsoft::Client::Email

Included in:
Infusionsoft::Client
Defined in:
lib/infusionsoft/client/email.rb

Overview

The Email service allows you to email your contacts as well as attaching emails sent elsewhere (this lets you send email from multiple services and still see all communications inside of Infusionsoft).

Instance Method Summary collapse

Instance Method Details

#email_add(title, categories, from, to, cc, bcc, subject, text_body, html_body, content_type, merge_context) ⇒ Object

Create a new email template that can be used for future emails

Parameters:

  • title (String)
  • categories (String)

    a comma separated list of the categories you want this template in Infusionsoft

  • from (String)

    the from address format use is ‘FirstName LastName <[email protected]>’

  • to (String)

    the email address this template is sent to

  • cc (String)

    a comma separated list of cc email addresses

  • bcc (String)

    a comma separated list of bcc email addresses

  • subject (String)
  • text_body (String)
  • html_body (String)
  • content_type (String)

    can be Text, HTML, Multipart

  • merge_context (String)

    can be Contact, ServiceCall, Opportunity, CreditCard



22
23
24
25
26
# File 'lib/infusionsoft/client/email.rb', line 22

def email_add(title, categories, from, to, cc, bcc, subject, text_body, html_body,
              content_type, merge_context)
  response = xmlrpc('APIEmailService.addEmailTemplate', title, categories, from, to,
                 cc, bcc, subject, text_body, html_body, content_type, merge_context)
end

#email_attach(contact_id, from_name, from_address, to_address, cc_addresses, bcc_addresses, content_type, subject, html_body, txt_body, header, receive_date, send_date) ⇒ Object

This will create an item in the email history for a contact. This does not actually send the email, it only places an item into the email history. Using the API to instruct Infusionsoft to send an email will handle this automatically.

Parameters:

  • contact_id (Integer)
  • from_name (String)

    the name portion of the from address, not the email

  • from_address (String)
  • to_address (String)
  • cc_addresses (String)
  • bcc_addresses (String)
  • content_type (String)

    can be Text, HTML, Multipart

  • subject (String)
  • html_body (String)
  • text_body (String)
  • header (String)

    the header info for this email (will be listed in history)

  • receive_date (Date)
  • sent_date (Date)


45
46
47
48
49
50
51
# File 'lib/infusionsoft/client/email.rb', line 45

def email_attach(contact_id, from_name, from_address, to_address, cc_addresses,
                 bcc_addresses, content_type, subject, html_body, txt_body,
                 header, receive_date, send_date)
  response = xmlrpc('APIEmailService.attachEmail', contact_id, from_name, from_address,
                 to_address, cc_addresses, bcc_addresses, content_type, subject,
                 html_body, txt_body, header, receive_date, send_date)
end

#email_get_available_merge_fields(merge_context) ⇒ Array

This retrieves all possible merge fields for the context provided.

Parameters:

  • merge_context (String)

    could include Contact, ServiceCall, Opportunity, or CreditCard

Returns:

  • (Array)

    returns the merge fields for the given context



57
58
59
# File 'lib/infusionsoft/client/email.rb', line 57

def email_get_available_merge_fields(merge_context)
  response = xmlrpc('APIEmailService.getAvailableMergeFields', merge_context)
end

#email_get_opt_status(email_address) ⇒ Integer

Retrieves the status of the given email address.

Parameters:

  • email_address (String)

Returns:

  • (Integer)

    0 = opted out, 1 = single opt-in, 2 = double opt-in



73
74
75
# File 'lib/infusionsoft/client/email.rb', line 73

def email_get_opt_status(email_address)
  response = xmlrpc('APIEmailService.getOptStatus', email_address)
end

#email_get_template(id) ⇒ Hash

Retrieves the details for a particular email template.

Parameters:

  • id (Integer)

Returns:

  • (Hash)

    all data for the email template



65
66
67
# File 'lib/infusionsoft/client/email.rb', line 65

def email_get_template(id)
  response = xmlrpc('APIEmailService.getEmailTemplate', id)
end

#email_optin(email_address, reason) ⇒ Boolean

This method opts-in an email address. This method only works the first time an email address opts-in.

Parameters:

  • email_address (String)
  • reason (String)

    This is how you can note why/how this email was opted-in. If a blank reason is passed the system will default a reason of “API Opt In”

Returns:

  • (Boolean)


85
86
87
# File 'lib/infusionsoft/client/email.rb', line 85

def email_optin(email_address, reason)
  response = xmlrpc('APIEmailService.optIn', email_address, reason)
end

#email_optout(email_address, reason) ⇒ Boolean

Opts-out an email address. Note that once an address is opt-out, the API cannot opt it back in.

Parameters:

  • email_address (String)
  • reason (String)

Returns:

  • (Boolean)


95
96
97
# File 'lib/infusionsoft/client/email.rb', line 95

def email_optout(email_address, reason)
  response = xmlrpc('APIEmailService.optOut', email_address, reason)
end

#email_send(contact_list, from_address, to_address, cc_addresses, bcc_addresses, content_type, subject, html_body, text_body) ⇒ Boolean

This will send an email to a list of contacts, as well as record the email in the contacts’ email history.

Parameters:

  • contact_list (Array<Integer>)

    list of contact ids you want to send this email to

  • from_address (String)
  • to_address (String)
  • cc_address (String)
  • bcc_address (String)
  • content_type (String)

    this must be one of the following Text, HTML, or Multipart

  • subject (String)
  • html_body (String)
  • text_body (String)

Returns:

  • (Boolean)

    returns true/false if the email has been sent



112
113
114
115
116
117
# File 'lib/infusionsoft/client/email.rb', line 112

def email_send(contact_list, from_address, to_address, cc_addresses,
               bcc_addresses, content_type, subject, html_body, text_body)
  response = xmlrpc('APIEmailService.sendEmail', contact_list, from_address,
                 to_address, cc_addresses, bcc_addresses, content_type, subject,
                 html_body, text_body)
end

#email_send_template(contact_list, template_id) ⇒ Object

This will send an email to a list of contacts, as well as record the email in the contacts’ email history.

Parameters:

  • contact_list (Array<Integer>)

    is an array of Contact id numbers you would like to send this email to

  • The (String)

    Id of the template to send

Returns:

  • returns true if the email has been sent, an error will be sent back otherwise.



125
126
127
# File 'lib/infusionsoft/client/email.rb', line 125

def email_send_template(contact_list, template_id)
  response = xmlrpc('APIEmailService.sendEmail', contact_list, template_id)
end

#email_update_template(id, title, category, from, to, cc, bcc, subject, text_body, html_body, content_type, merge_context) ⇒ Boolean

This method is used to update an already existing email template.

Parameters:

  • id (Integer)
  • title (String)
  • category (String)
  • from (String)
  • to (String)
  • cc (String)
  • bcc (String)
  • String (String subject)

    subject

  • text_body (String)
  • html_body (String)
  • content_type (String)

    can be Text, HTML, Multipart

  • merge_context (String)

    can be Contact, ServiceCall, Opportunity, CreditCard

Returns:

  • (Boolean)

    returns true/false if teamplate was updated successfully



145
146
147
148
149
# File 'lib/infusionsoft/client/email.rb', line 145

def email_update_template(id, title, category, from, to, cc, bcc, subject,
                          text_body, html_body, content_type, merge_context)
  response = xmlrpc('APIEmailService.updateEmailTemplate', id, title, category, from,
                 to, cc, bcc, subject, text_body, html_body, content_type, merge_context)
end