2017-08-28 48 views
0

添加鏈接的消息我其實寫一個SOAP命令(從JavaScript)Outlook加載發送郵件(到Exchange Server上運行)。在郵件中,我想要在2個不同的行中包含2個超鏈接。截至目前,代碼如下:在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); 
      } 

正如你所看到的,我有我的參數MyMessage,這我是單獨構建,如下面的例子來表示;

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

任何想法如何使用兩個鏈接之間的換行符超鏈接。 &#10;也不起作用。

回答

0

最後,我設法找到了解決這個問題的方法。通過將Body type指定爲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正確顯示,不添加#在鏈接的前面。