Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Tuesday, March 20, 2012

Sending Subject & Body to Outlook in HTML Format using JavaScript

<html>
<head>
<script language='Javascript'>
function OpenOutlook()
{
   
try
{

var outlookApp = new ActiveXObject("Outlook.Application");
var nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.add('IPM.Note.FormA');
mailItem.Subject="Me";
//mailItem.To = "me@me.com";
mailItem.HTMLBody = document.getElementById('tdBody').innerHTML;
mailItem.display (0);
}
catch(e)
{
alert(e);
// act on any error that you get
}

}
</script>

</head>
<body>
<form>
<table width='100%' cellpadding='0' cellspacing='0' >
<tr>
<td id='tdBody'>
<table width='100%' cellpadding='0' cellspacing='0' bgcolor='Aqua' border='1' >
<tr><td>FName</td><td>Prasad</td></tr>
<tr><td>City</td><td>Hyderabad</td></tr>
<tr><td>Telno</td><td>12345678</td></tr>
</table>
</td>
</tr>
</table>

<a href='JavaScript:OpenOutlook();'>Sample</a>

</form>
</body>
</html>

No comments:

Post a Comment