13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/ews_mail.rb', line 13
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
|