在SOAP指令中添加链接消息

时间:2017-08-28 12:47:18

标签: javascript soap exchange-server outlook-addin

我实际上正在编写一个SOAP命令(来自javascript),用于 Outlook加载项,用于发送邮件(在Exchange Server上运行)< / em>的。在邮件中,我想在2个不同的行中包含2个超链接。截至目前,代码如下;

{ 

                var soapNotificationItem = '<?xml version="1.0" encoding="utf-8"?>' +
                    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
                    '               xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"' +
                    '               xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
                    '               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
                    '               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
                    '  <soap:Header>' +
                    '    <RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" />' +
                    '  </soap:Header>' +
                    '  <soap:Body>' + 
                    '    <m:CreateItem MessageDisposition="SendAndSaveCopy">' +
                    '      <m:Items>' + 
                    '<t:Message>'+
                    '<t:Subject>Notification email</t:Subject>'+
                    '<t:Body BodyType="HTML">' + MyMessage + '</t:Body>' +
                    ' <t:ExtendedProperty>' +
                    ' <t:ExtendedFieldURI PropertyTag="16367" PropertyType="SystemTime" />'+
                    '<t:Value>2014-01-02T21:09:52.000</t:Value>'+
                    '</t:ExtendedProperty>'+
                    '<t:ToRecipients>' + MyMailAdd + '</t:ToRecipients>' +
                    '</t:Message>'+

                    '      </m:Items>' +
                    '    </m:CreateItem>' +
                    '  </soap:Body>' +
                    '</soap:Envelope>';
                mailbox.makeEwsRequestAsync(soapNotificationItem, soapNotificationItemCallback);
            }

正如您所看到的,我有我的参数MyMessage,我正在单独构建,如下例所示;

MyMessage = "www.mylink1.com" + "&#10;" + "www.mylink2.com" 

任何想法如何从2个链接中创建超链接,其间有换行符。 &#10;也不起作用。

1 个答案:

答案 0 :(得分:0)

最后,我设法找到了解决问题的方法。通过将Body类型指定为HTML <t:Body BodyType="HTML">,我可以添加简单的HTML。

为了简化,HTML结构遵循以下格式,但在我的情况下,我正在从XML文件中读取数据,循环并连接要显示的消息。

var link1 = "www.test.com"
var MyMessage = "<strong>Click on link :</strong>: <a href=\"#" + link1  + "\">" + Link1 + "</a>";

然后进入 SOAP 部分,它仍保持原样;     {

            var soapNotificationItem = '<?xml version="1.0" encoding="utf-8"?>' +
                '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
                '               xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"' +
                '               xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
                '               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
                '               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
                '  <soap:Header>' +
                '    <RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" />' +
                '  </soap:Header>' +
                '  <soap:Body>' + 
                '    <m:CreateItem MessageDisposition="SendAndSaveCopy">' +
                '      <m:Items>' + 
                '<t:Message>'+
                '<t:Subject>Notification email</t:Subject>'+
                '<t:Body BodyType="HTML">' + MyMessage + '</t:Body>' +
                ' <t:ExtendedProperty>' +
                ' <t:ExtendedFieldURI PropertyTag="16367" PropertyType="SystemTime" />'+
                '<t:Value>2014-01-02T21:09:52.000</t:Value>'+
                '</t:ExtendedProperty>'+
                '<t:ToRecipients>' + MyMailAdd + '</t:ToRecipients>' +
                '</t:Message>'+

                '      </m:Items>' +
                '    </m:CreateItem>' +
                '  </soap:Body>' +
                '</soap:Envelope>';
            mailbox.makeEwsRequestAsync(soapNotificationItem, soapNotificationItemCallback);
        }

注意:要使链接在Office365中正确显示,请在链接前添加#