0

我正在尝试将带有 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 “实例”方法,但无法初始化消息对象的实例以使用它。

4

1 回答 1

0

技巧是设置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
于 2013-11-19T17:34:28.630 回答