Method: Osm::Email.send_email

Defined in:
lib/osm/email.rb

.send_email(api, section, send_to, cc = '', from, subject, body) ⇒ Boolean

Get a list of selected email address for selected members ready to pass to send_email method

Parameters:

  • api (Osm::Api)

    The api to use to make the request

  • section (Osm::Section, Fixnum, #to_i)

    The section (or its ID) to send the message to

  • send_to (Hash)

    Email addresses to send the email to: member_id -> [String], lastname [String], emails [Array<String>]

  • cc (String, nil) (defaults to: '')

    Email address (if any) to cc

  • from (String)

    Email address to send the email from

  • from (String)

    Email subject The subject of the email

  • from (String)

    Email body The bosy of the email

Returns:

  • (Boolean)

    Whether OSM reported the email as sent



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/osm/email.rb', line 51

def self.send_email(api, section, send_to, cc='', from, subject, body)
  data = api.perform_query('ext/members/email/?action=send', {
    'sectionid' => section.to_i,
    'emails' => send_to.to_json,
    'scouts' => send_to.keys.join(','),
    'cc' => cc,
    'from' => from,
    'subject' => subject,
    'body' => body,
  })

  return data.is_a?(Hash) && data['ok']
end