module EWS::Mail
Mail
module
Constants
Public Class Methods
send(username:, password:, rcpts:, subject:, body:)
click to toggle source
Send mail via EWS
.
Senders is determined automatically by EWS
based on your username.
Example¶ ↑
username: '<USERNAME>', password: '<PASSWORD>', rcpts: '<RECIPIENT>', subject: '<SUBJECT>', body: '<PLAINTEXT-BODY>'
username: '<USERNAME>', password: '<PASSWORD>', rcpts: ['<RECIPIENT1>', '<RECIPIENT2>'], subject: '<SUBJECT>', body: '<PLAINTEXT-BODY>'
)
# File lib/ews_mail.rb, line 39 def self.send(username:, password:, rcpts:, subject:, body:) c = Savon.client({ wsdl: WSDL, endpoint: ENDPOINT, basic_auth: [username, password], namespaces: NAMESPACES, }) message = { 'tns:Items' => { 't:Message' => { 't:Subject' => subject, 't:Body' => body, 't:ToRecipients' => { 't:Mailbox' => [*rcpts].map do |v| { 't:EmailAddress' => v } end }, attributes!: { 't:Body' => { 'BodyType' => 'Text' } } } }, } attributes = { 'MessageDisposition' => 'Send' } c.call(:create_item, message: message, attributes: attributes) end