Solved

Creating a client-side Outlook application

Posted on 2004-08-24
27
738 Views
Last Modified: 2012-08-13
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
Comment
Question by:RichardFox
  • 15
  • 8
  • 4
27 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 11886663
make a link with the mailto: protocoll and that is all what you need to do.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11886703
Here an example:

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

0
 

Author Comment

by:RichardFox
ID: 11886773
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 11886861
You need for that to call ActiveXObject. That will produce a warning to the user. Is that acceptable for you?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11886875
And of course, ActiveXObject is limmitation to IE browsers.
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11886890
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 11886905
Thank you Zyloch.
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11886910
No problem. Just wondering, Zvonko, where would you recommend me to start learning ActiveX? I have no idea about them.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11886939
Ok, for you Zyloch and for RichardFox.
Start learning Outlook ActiveX by pressing ALT-F11 in Outlook.
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11886964
I'm gonna put that on my license plate one day :) thanks
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11886973
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 11887000
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 11887056
RichardFox, you did not answer my questions? Is ActiveX acceptable for you?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:RichardFox
ID: 11887303
SOrry, I was driving home. Yes, ActiveX is an acceptable option.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11887340
Ok, I will try to make a basic framework that you can extend to your needs.
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11887356
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
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 11887711
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
 

Author Comment

by:RichardFox
ID: 11892695
I have to play around with this... looks promising
0
 

Author Comment

by:RichardFox
ID: 11893092
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
 

Author Comment

by:RichardFox
ID: 11895004
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 11897032
That could be a browser setting.
What browser version are you testing?
0
 

Author Comment

by:RichardFox
ID: 11897096
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
 

Author Comment

by:RichardFox
ID: 11897168
HAHAHAHA! Got it! You were right, it was the browser, I had to allow ActiveX controls to run, browser settings.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11897171
Fine!
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11897192
Can I please see your working version?
0
 

Author Comment

by:RichardFox
ID: 11897220
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 11897313
Thank you very much. Now it works for me too :-)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now