Ruby Viewpoint Gem 1.27

时间:2013-05-17 13:11:32

标签: ruby

我尝试使用Viewpoint Ruby Gem向EWS端点发送消息。我只能以纯文本格式发送消息。如何以html格式发送?

以下是代码:

Viewpoint::EWS::EWS.endpoint=Conf.application.email.ews.endpoint
Viewpoint::EWS::EWS.set_auth(Conf.application.email.ews.username,Conf.application.email.ews.password)
Viewpoint::EWS::Message.send(options[:subject],msg_str,to_addresses)

我看到有一个text_only"实例"方法,但无法初始化消息对象的实例以使用它。

1 个答案:

答案 0 :(得分:0)

Trick是设置body_type。注意:此示例源自https://github.com/zenchild/Viewpoint基于v1.0beta的示例。

require 'viewpoint'
include Viewpoint::EWS

endpoint = 'https://example.com/ews/Exchange.asmx'
user = 'username'
pass = 'password'

cli = Viewpoint::EWSClient.new endpoint, user, pass
cli.send_message do |m|
  m.subject = "Test"
  m.body    = "<html><body><strong>Test</strong> message</body></html>"
  m.body_type = 'HTML'
  m.to_recipients << 'test@example.com'
end