Solved

How do I populate an Outlook Template from a Web Page?

Posted on 2008-06-18
7
564 Views
Last Modified: 2010-04-21
Dear Experts,

I am developing a web-based CRM application where users can click a hyperlink to open an email template which is populated with the customer's email address and name.

The attached code opens an Outlook template ("Testy"), however I am struggling to figure out how to populate the template with the customer's email and name.

My web server does not support VB, so I need to do this in Java.

Any help would be greatly appreciated.

Thanks much!!!
<html> 
<head> 
<script language="JavaScript" type="text/JavaScript"> 
<!--
   // Variable Definitions 
   var outlookApp = null; 
   var nameSpace = null; 
   var mailFolder = null; 
   var mailItem = null; 
   var tempDoc = null; 
 
   function OpenOutlookDoc(whatform) 
   { 
      try 
      { 
      outlookApp = new ActiveXObject("Outlook.Application"); 
      nameSpace = outlookApp.getNameSpace("MAPI"); 
      mailFolder = nameSpace.getDefaultFolder(6); 
      mailItem = mailFolder.Items.add(whatform); 
      mailItem.Display(0)
      } 
      catch(e) 
      { 
      // act on any error that you get 
      } 
   } 
--> 
</script> 
</head> 
<body> 
<form> 
To use form buttons:<br> 
<input type=button value="Form A" NAME="OutlookOpen1" OnClick="OpenOutlookDoc('IPM.Note.Testy')"><br><br> 
To use text links:<br> 
<a href=javascript:void(0) onClick="OpenOutlookDoc('IPM.Note.Testy')">Form A</a><br><br> 
<!-- change the information between the single quotes to match your custom forms class Name like IPM.Note.CustomForm - you can have different links to different forms, provided you specify a different class Name for each link //--> 
</form> 
</body> 
</html>

Open in new window

0
Comment
Question by:Ragnar64
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 21833526
You cannot read by script email addresses in Outlook because that is blocked by a security patch.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 21833559
Or do you have the address already?
Then it goes simply as this:
   function OpenOutlookDoc(whatform) 
   { 
      try 
      { 
      outlookApp = new ActiveXObject("Outlook.Application"); 
      nameSpace = outlookApp.getNameSpace("MAPI"); 
      mailFolder = nameSpace.getDefaultFolder(6); 
      mailItem = mailFolder.Items.add(whatform);
      mailItem.To = "Ragnar64@some.net";
      mailItem.Subject = "eMail for you";
      mailItem.Body = "eMail for you.";
 
      mailItem.Display(0)
      } 
      catch(e) 
      { 
      // act on any error that you get 
      } 
   } 

Open in new window

0
 

Author Closing Comment

by:Ragnar64
ID: 31468472
Zvonko - you're the King!!

Thank you very much for your help, I've been struggling with this for over a week.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Ragnar64
ID: 21835521
Zvonko - perfect, exactly what I needed, thank you very much!

Just one more thing please - my Outlook template has a user defined variable named "pig". Can you please tell me how to pass a value to this variable in the template? Something like mailItem.UserProperties.pig = "bacon";

Thanks again for all your help.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 21840025
Open a new Question please.

You can post here the question number when you have opened the related question.
There is also a Related Question feature on EE but I seldom open questions :)
0
 

Author Comment

by:Ragnar64
ID: 21841011
Follow-up question posted to : http://www.experts-exchange.com/Programming/Languages/Java/Q_23505744.html

Thanks for your help Zvonko!!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question