Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 798
  • Last Modified:

Creating a client-side Outlook application

I have a need to send an Outlook appointment item from my web page. Since this web page is only used internally, I know that all users have Outlook installed. I want to send an Outlook appointment item via email to several recipients. Does anyone know how to create an Outlook application in javascript?

Thanks,

RF
0
RichardFox
Asked:
RichardFox
  • 15
  • 8
  • 4
1 Solution
 
ZvonkoSystems architectCommented:
make a link with the mailto: protocoll and that is all what you need to do.
0
 
ZvonkoSystems architectCommented:
Here an example:

<a href="mailto:RichardFox@company.com?CC=%20&BCC=%20&Subject=IX%20Customer%20Services%20Team&Body=line1%0Dline2">Mail</a>

0
 
RichardFoxAuthor Commented:
OK, I guess you are saying that will activate the user's default mail client, in this case Outlook, and send the email. But

1. I need a function I can call, not a link
2. I need to send an Outlook appointment, for which I need to create an Outlook app, create an appointment item, set the invitees, and send (I think)
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!

 
ZvonkoSystems architectCommented:
You need for that to call ActiveXObject. That will produce a warning to the user. Is that acceptable for you?
0
 
ZvonkoSystems architectCommented:
And of course, ActiveXObject is limmitation to IE browsers.
0
 
ZylochCommented:
Hi

I'm not familiar with Outlook ActiveX, but you'd create an object like this:

var myOutlook = new ActiveXObject("Outlook.Application");

Regards,
Zyloch
0
 
ZvonkoSystems architectCommented:
Thank you Zyloch.
0
 
ZylochCommented:
No problem. Just wondering, Zvonko, where would you recommend me to start learning ActiveX? I have no idea about them.
0
 
ZvonkoSystems architectCommented:
Ok, for you Zyloch and for RichardFox.
Start learning Outlook ActiveX by pressing ALT-F11 in Outlook.
0
 
ZylochCommented:
I'm gonna put that on my license plate one day :) thanks
0
 
ZvonkoSystems architectCommented:
Next step is to go to Menu in VisualBasic: View->Object Catalog (I don't know the exact menu labels because my Outlook is in German)
0
 
ZvonkoSystems architectCommented:
Next step is to select in Object viewer the Outlook library. And you have to know that all object trees root start for Microsoft in: Application
0
 
ZvonkoSystems architectCommented:
RichardFox, you did not answer my questions? Is ActiveX acceptable for you?
0
 
RichardFoxAuthor Commented:
SOrry, I was driving home. Yes, ActiveX is an acceptable option.
0
 
ZvonkoSystems architectCommented:
Ok, I will try to make a basic framework that you can extend to your needs.
0
 
ZylochCommented:
I'll leave this to you, Zvonko, but imagine the headlines:

April 1, 2050

Working on Laptop While Driving is Banned. There has Been a Dramatic Increase in Accidents after Microsoft has Started Monopolizing the Car Industry by Installing Laptops in their Computers

SUBTITLE: Viewers should also be warned that Microsoft has installed a bug on everyone of those laptops so their employees who are too nerdish to get a girlfriend will know just when you break it off with your girlfriend and when they are vulnerable.


Sorry for the OT post, but I'm bored, so what do you know ;)
0
 
ZvonkoSystems architectCommented:
Thanks for the warning, but I am married ;-)
Neverteless I have to go to bed.
So here my unfinished code:

<html>
<head>
<style>
TH {
  text-align: right;
}
.mid {
  text-align: center;
}
INPUT {
  width: 260px;
}
.btn {
  width: 120px;
}
</style>
<script>
function createApointment(theBtn){
  olAppointmentItem = 1;
  olOutOfOffice = 3;
  olPrivate = 2;
  olVCal = 7;
  theForm = theBtn.form;
  vSubject = theForm.Subject.value;
  vPlace = theForm.Place.value;
  vStartTime = theForm.StartTime.value;
  vDuration = theForm.Duration.value;
  vReminderTime = theForm.ReminderTime.value;
  vBody = theForm.Body.value;
  objApp = new ActiveXObject("Outlook.Application");
  objAppointment = objApp.CreateItem(olAppointmentItem);
  with(objAppointment){
    Subject = vSubject;
    Location = vPlace;
    Start = vStartTime;
    Duration = vDuration;
    ReminderMinutesBeforeStart = vReminderTime;
    BusyStatus = olOutOfOffice;
    Body = vBody;
    Sensitivity = olPrivate
    SaveAs("", olVCal);
    Display
  }
}
</script>
</head>
<body>
<form>
<table>
<tr><th colspan="2" class="mid">Apointment</th></tr>
<tr><th>Subject</th><td>
<input type=text name="Subject" value="Meeting">
</td></tr>
<tr><th>Place</th><td>
<input type=text name="Place" value="My Office">
</td></tr>
<tr><th>Start Time</th><td>
<input type=text name="StartTime" value="21.11.2004 15:30">
</td></tr>
<tr><th>Duration</th><td>
<input type=text name="Duration" value="90">
</td></tr>
<tr><th>ReminderTime</th><td>
<input type=text name="ReminderTime" value="45">
</td></tr>
<tr><th colspan="2" class="mid">Text</th></tr>
<tr><td colspan="2">
<textarea name="Body" cols="40" rows="7">
Bring Beer!
</textarea>
</td></tr>
</table>
<input type=button value="Add Appointment" class="btn"" onClick="createApointment(this)">
</form>
</body>
</html>

The path is wrong for SaveAS, and I have no idea what the path could be :(

0
 
RichardFoxAuthor Commented:
I have to play around with this... looks promising
0
 
RichardFoxAuthor Commented:
What I have so far, less ambitious than your version.. it does have the drawback that it doesn't work

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Appointment Tester</title>
<script language=javascript>
            function createAppointment()
            {
                  Response.Write
                  olAppointmentItem = 1;
                  oApp = new ActiveXObject("Outlook.Application");
                  oNam = oApp.GetNamespace("MAPI");
                  oObx = oNam.GetDefaultFolder(4);
                  oApt = oApp.CreateItem(olAppointmentItem);
                  oApt.MeetingStatus = 1;
                  recip = oApt.Recipients.Add("rfox@esops.com");
                  recip.Type = 1
                  recip.Resolve();
                  oApt.Subject = "My meeting";
                  oApt.Start = #8/25/2004 1:30:00 PM#;
                  oApt.Duration = 5;
                  oApt.Send();
            }
</script>
</head>
<body>
      <form ID="Form1">
            <input type="button" value="Add Appointment" onclick="createAppointment()" ID="Button1" NAME="Button1">
      </form>
</body>
</html>
0
 
RichardFoxAuthor Commented:
Yeah, I can't even create the active X object

<html>
<head>
<title>Appointment Tester</title>
<script language=javascript>
                   
    function createapt()
    {
         myOlApp = new ActiveXObject("Outlook.Application")
    }
   
</script>
</head>
<body>
    <form ID="Form1">
         <input type="button" value="Add Appointment" onclick="createapt();" ID="Button1" NAME="Button1">
    </form>
</body>
</html>

help!
0
 
ZvonkoSystems architectCommented:
That could be a browser setting.
What browser version are you testing?
0
 
RichardFoxAuthor Commented:
IE 6.0

I get "Automation server can't create object". I got the Outlook object working server side, as follows

private void sendAppointment(  )
{
try
{      Outlook._Application oApp = new Outlook.ApplicationClass();
      Outlook.NameSpace mapiNS = oApp.GetNamespace("MAPI");
      string profile = "MS Exchange Settings";
      mapiNS.Logon(profile, null, null, null);

      // Use the Outlook application object to create an appointment
      Outlook._AppointmentItem apt = (Outlook._AppointmentItem)
            oApp.CreateItem(Outlook.OlItemType.olAppointmentItem);

      // set some properties
      apt.Subject = "whatever";
      apt.Body = apt.Subject;

      apt.Start = DateTime(2001,12,31);
      apt.End   = ddate.AddHours(1);

      apt.ReminderMinutesBeforeStart = 1;

      // Makes it appear bold in the calendar - which I like!
      apt.BusyStatus = Outlook.OlBusyStatus.olTentative;
      apt.Recipients.Add(@"rfox@myserver.com");
      apt.AllDayEvent = false;
      apt.Location = "";
      apt.Save();
}
catch (Exception ev)
{
      HttpContext.Current.Response.Write("<BR>"+ev.Message);
}

And a calendar item was added to my calendar. But, this is less than ideal. I really want to do this client side - in order to get it to run on the (intranet) server I had to change the user that ASP.NET is running as to myself, which is pretty unsafe! But I am still just testing.

I would love to get this running in javascript.
0
 
RichardFoxAuthor Commented:
HAHAHAHA! Got it! You were right, it was the browser, I had to allow ActiveX controls to run, browser settings.
0
 
ZvonkoSystems architectCommented:
Fine!
0
 
ZvonkoSystems architectCommented:
Can I please see your working version?
0
 
RichardFoxAuthor Commented:
Sure, still lots hardcoded but I am hooking it up now. thanks very much, by the way

function sendappointment()
{
      olAppointmentItem = 1;
      oApp = new ActiveXObject("Outlook.Application");
      oNam = oApp.GetNamespace("MAPI");
      oOutbx = oNam.GetDefaultFolder(4);
      oApt = oApp.CreateItem(olAppointmentItem);
      oApt.MeetingStatus = 1;
      recip = oApt.Recipients.Add("rfox@myserver.com");
      recip.Type = 1;
      recip.Resolve();
                // add other recipients by repeating last 3 lines
      oApt.Subject = "My meeting";
      oApt.Start = "8/25/2004 1:30:00 PM";
      oApt.Duration = 5;
      oApt.Send();
}
0
 
ZvonkoSystems architectCommented:
Thank you very much. Now it works for me too :-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 15
  • 8
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now