点击界面某一按钮,即弹出Outlook 新建邮件的UI,且发件人、收件人、邮件标题、包括部分固定的邮件内容均已显示。代码如下:
<script language="javascript" type="text/javascript">
function SendMail()
{
var objTextBox2 = document.getElementById("<%=userName.ClientID %>").value;
var outlookApp = new ActiveXObject("Outlook.Application");
var nameSpace = outlookApp.getNameSpace("MAPI");
var mailItem = outlookApp.CreateItem(0);
var mailto = "Britney.Zhang@astrazeneca.com";
var mailBody
mailBody="<html>"
mailBody=mailBody + "<head>"
mailBody=mailBody + "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>"
mailBody=mailBody + "<style>"
mailBody=mailBody + "<!--"
mailBody=mailBody + "@font-face {font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;}"
mailBody=mailBody + "p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; text-align:justify;text-justify:inter-ideograph; font-size:10.5pt; font-family:\"Times New Roman\";}"
mailBody=mailBody + "a:link, span.MsoHyperlink {color:blue; text-decoration:underline;}"
mailBody=mailBody + "a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;}"
mailBody=mailBody + "span.EmailStyle16 {mso-style-type:personal-compose; font-family:Arial; color:windowtext;}"
mailBody=mailBody + "@page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; layout-grid:15.6pt;}"
mailBody=mailBody + "div.Section1 {page:Section1;}"
mailBody=mailBody + "//-->"
mailBody=mailBody + "</style>"
mailBody=mailBody + "</head>"
mailBody=mailBody + "<BODY lang=EN-US style=\"tab-interval: 36.0pt\" bgColor=#EDDFEC>"
mailBody=mailBody + "<DIV class=Section1>"
mailBody=mailBody + "<P class=MsoNormal><SPAN class=EmailStyle16><FONT face=宋体 color=black size=2>新产品推荐</FONT></SPAN><SPAN class=EmailStyle16></SPAN>"
mailBody=mailBody + "<SPAN class=EmailStyle16></SPAN></P>"
mailBody=mailBody + "<br>"
mailBody=mailBody + "<P class=MsoNormal><SPAN class=EmailStyle16><FONT face=宋体 color=black size=2>产品名称:</FONT></SPAN><SPAN class=EmailStyle16><FONT face=Arial color=black size=2><U> </U></FONT></SPAN>"
mailBody=mailBody + "<SPAN class=EmailStyle16></SPAN></P>"
mailBody=mailBody + "<br>"
mailBody=mailBody + "<P class=MsoNormal><SPAN class=EmailStyle16><FONT face=Arial color=black size=2>产品型号:</FONT></SPAN><SPAN class=EmailStyle16><FONT face=Arial color=black size=2><U> </U></FONT></SPAN>"
mailBody=mailBody + "<SPAN class=EmailStyle16></SPAN></P>"
mailBody=mailBody + "<br>"
mailBody=mailBody + "<P class=MsoNormal><SPAN class=EmailStyle16><FONT face=Arial color=black size=2>产品描述:</FONT></SPAN><SPAN class=EmailStyle16><FONT face=Arial color=black size=2><U> </U></FONT></SPAN>"
mailBody=mailBody + "<SPAN class=EmailStyle16></SPAN></P>"
mailBody=mailBody + "<br>"
mailBody=mailBody + "<P class=MsoNormal><SPAN class=EmailStyle16><FONT face=Arial color=black size=2>产品图片或Internet链接:attached file或html</FONT></SPAN><SPAN class=EmailStyle16><FONT face=Arial color=black size=2><U> </U></FONT></SPAN>"
mailBody=mailBody + "<SPAN class=EmailStyle16></SPAN></P>"
mailBody=mailBody + "<br>"
mailBody=mailBody + "<P class=MsoNormal><SPAN class=EmailStyle16><FONT face=Arial color=black size=2>预计价格:</FONT></SPAN><SPAN class=EmailStyle16><FONT face=Arial color=black size=2><U> </U></FONT></SPAN>"
mailBody=mailBody + "<SPAN class=EmailStyle16></SPAN></P>"
mailBody=mailBody + "<br>"
mailBody=mailBody + "<P class=MsoNormal><SPAN class=EmailStyle16><FONT face=Arial color=black size=2>其他反馈意见:</FONT></SPAN><SPAN class=EmailStyle16><FONT face=Arial color=black size=2><U> </U></FONT></SPAN>"
mailBody=mailBody + "<SPAN class=EmailStyle16></SPAN></P>"
mailBody=mailBody + "</BODY>"
mailBody=mailBody + "</html>"
mailItem.Subject="我要推荐礼品";
mailItem.To=mailto;
mailItem.HTMLBody = mailBody;
mailItem.Display(0);
mailItem=null;
nameSpace=null;
outlookApp=null;
}
</script>
<table width="650px">
<tr>
<td align="center" style="width: 100%">
</td>
</tr>
<tr>
<td style="width: 100%" align="center">
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/DesktopModules/GetEgiftFeedback/egift1.jpg" OnClientClick="SendMail()" /></td>
</tr>
</table>
<input id="userName" runat="server" style="width: 81px" type="hidden" />
<a href="javascript;" οnclick="SendMail();return false;">或者点击此处</a>
转载于:https://www.cnblogs.com/BritneyComeOn/archive/2009/06/16/1504432.html