Link to home
Start Free TrialLog in
Avatar of sbornstein2
sbornstein2

asked on

Classic ASP 3.0 question - can an outlook task be created within code?

Hello all,

I have an old ASP 3.0 application.  I beleive my client uses exchange but I need to double check.  They want to based on after a new item is created from one of my forms, create an outlook task specified to a certain person.  Any idea if this is possible?  I assume I have to find out for sure about exchange as it may need to be completed there if it is to a certain person.  So I know this is preliminary info here.
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

If ASP supports VBA ... then the answer is yes, VBA can be used to connect to or open outlook as necessary and a task can be dynamically created and populated from the relevant data.

Chris
sbornstein2

If you are happy following links then that is fine, I mean no offence to your skills when I say my intent is to try and walk you through the process.  I have trialled a task send to a user and am perfectly happy automating outlook so hopefully can provide such support as you would like.

Chris
Problem with this is: If you are using ASP your code is server side. You need to install Outlook on server and you can not access outlook on a specific client. To do this you would have to run an iis web server on each client.

You have to know if there is an exchange server, and if so, try to access this directly. I do not have any code examples. Here is only a short one for connecting to exchange:
http://www.codeproject.com/KB/asp/Exchange_ADSI_LDAP.aspx

A code example for new calender entry in outlook:
Set myOLApp = CreateObject("Outlook.Application")
Set myItem = myOLApp.CreateItem(olAppointmentItem)
With myItem
.Start = "01.02.97 10:00:00"
.End = "01.02.97 16:00:00"
.Subject = "Präsentation der neuen Werbekampagne"
.Save
.Display
End With
Set myItem = Nothing
Set myOLApp = Nothing

Open in new window

DarthSonic

You may well know more than I but I would be cautious about statements such as "you can not access outlook on a specific client" which can be misleading.  Using VBA if ASP supports it you can createa task which may well require otlook on the server, but if so and there is such an install then you can most definitely create a task that can be sent to the specific client.  Whether they choose to accept it is another matter.

Personally I am waiting for the author to come online so we can establish teh environment, capability and need before getting too stuck in.

Chris
You can not use VBA in ASP, you can only use "VBScript" or JavaScript. Both could be used also for client side scripts but there is no ActiveX object for Outlook or Exchange client side within the browsers as far as I know.
DarthSonic

That helps, in VBS of course we can use to all intents and purposes VBA code as indicated in your earlier snippet so I see no problem as long as there is instance of outlook installed on the server.  If not I wouldn't rule it out but I don't know currently if we can connect to exchange in the same way.

Chris
Avatar of sbornstein2
sbornstein2

ASKER

Hey guys,

Thanks for all the input I will be trying some things over the next few nights.  I beleive I can use the Outlook.Application create object and I think possibly create a request task to a user.  I found one link but I need to test things.  They do use exchange I found out but I am hoping I don't have to worry about exchange and somehow send a create task request for a user or something.  I will keep ya posted and will award this question very soon.  Thanks again and have a great begin to the week.
When you're looking the snippet is the code I used to send a task to a user.  Simply add the correct email address in place of the recipient and owner.

Chris
Sub otherPerson()
Dim nuTask As Outlook.TaskItem
 
    Set nuTask = Application.CreateItem(olTaskItem)
    With nuTask
        .DueDate = Date + 7 + TimeValue("10:00:00")
        .ReminderTime = Date + 5 + TimeValue("15:00:00")
        .subject = "Delete Me"
        .Body = "Auto Generated by me"
        .Recipients.Add "email@address"
        .Owner = "email@address"
        .Assign
        .Send
        .Delete
    End With
    Set nuTask = Nothing
 
End Sub

Open in new window

will do Chris.  thanks a lot.  I will paste also the link I found when I get home from work to see if that is similar to what I need as well.
chris_bottomleys code translated to asp would be:
Sub otherPerson()
 
    Dim nuTask
 
    Set outlookApp = CreateObject("Outlook.Application")
    Set nuTask = outlookApp.CreateItem(olTaskItem)
 
    With nuTask
 
        .DueDate = Date + 7 + TimeValue("10:00:00")
        .ReminderTime = Date + 5 + TimeValue("15:00:00")
        .subject = "Delete Me"
        .Body = "Auto Generated by me"
        .Recipients.Add "email@address"
        .Owner = "email@address"
        .Assign
        .Send
        .Delete
 
    End With
 
    Set nuTask = Nothing
    Set outlookApp = Nothing
 
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DarthSonic:

LOoks like you were close but olTaskItem is an outlook constant therefore replacing with the magic number or creation of a constant is required.

Chris
thanks all
Glad to help

Chris