在SAP BSP view里显示outlook inbox里的邮件
作者:互联网
Created by Jerry Wang, last modified on Jun 16, 2014
在ui component里面创建一个空的view,copy paste如下的javascript代码,
<%@page language="abap" %>
<%@extension name="thtmlb" prefix="thtmlb" %>
<%@extension name="chtmlb" prefix="chtmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<div id = "main">
<TABLE id="mtable" border=1>
<tbody id="mtbody">
<TR id="mtr">
<TD>SenderName</TD>
<TD>ReceivedTime</TD>
<TD>To</TD>
<TD>CC</TD>
<TD>Subject</TD>
<TD>Body</TD>
</TR>
</tbody>
</TABLE>
</div>
<script language = "javascript">
function init()
{
var body = document.getElementById("mtbody");
var l_mails = getAllMails( );
render(l_mails, body);
}
function getAllMails()
{
var oi_oApp = new ActiveXObject("Outlook.Application");
var olFolderInbox = 6;
var l_inboxFoder = oi_oApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox);
var l_items = l_inboxFoder .Items.Restrict("[MessageClass] >= 'IPM.Note'");
l_items.Sort("ReceivedTime",true);
return l_items;
}
function render(p_Items, pUIElement)
{
var tr = document.getElementById("mtr");
for( var i =0; i < p_Items.count; i++ ) {
var newTr = tr.cloneNode(true);
var children = newTr.children;
var mailItem = p_Items(i+1);
for( var j = 0 ; j < children.length; j++) {
var item = children.item(j);
switch(j) {
case 0:
item.innerHTML = mailItem.SenderName;
break;
case 1:
item.innerHTML = mailItem.ReceivedTime;
break;
case 2:
item.innerHTML = mailItem.To;
break;
case 3:
item.innerHTML = mailItem.CC;
break;
case 4:
item.innerHTML = mailItem.Subject;
break;
case 5:
item.innerHTML = mailItem.Body.substr(0,20);
break;
}
}
pUIElement.appendChild(newTr);
}
}
init();
</script>
打开IE的activeX之后就能看到如下的outlook邮件列表.
标签:case,outlook,mailItem,BSP,innerHTML,break,item,inbox,var 来源: https://blog.csdn.net/i042416/article/details/94720897