2013-05-17 65 views
0

我试图用Viewpoint Ruby Gem向EWS端点发送消息。我只能以纯文本格式发送消息。我怎样才能以html格式发送它?Ruby Viewpoint Gem 1.27

下面是代码:

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“实例”的方法,但我不能初始化消息对象的实例来使用它。

回答

0

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

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 << '[email protected]' 
end