problem with this code - outlook tasks

O

outlook

Hello, I am retrieving all tasks from Outlook which categories are
"home". But when I run this code and do some changes directly in Outlook
like update progress or change due date,etc., and refresh the Html page,
I don't see those changes in my Html page. I only see them if I rebuild
the all project again. It seems that my local variables are not getting
the last value from Outlook and are keeping the old values.

I will papreciate some suggestions please , thanks

Imports Outlook = Microsoft.Office.Interop.Outlook
Imports System.Web.UI.HtmlTextWriter
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.ComponentModel
Public Class WebForm1

Private _outlook As Outlook.Application
Private _nSpace As Outlook.NameSpace
Private flr As Outlook.MAPIFolder
Private taskFolder As Outlook.MAPIFolder
Private tasks As New Object

Sub gettasks()
Dim strSubject As String

Dim I As Integer
Dim NumItems As Integer

Dim task As New Object
Dim strCategories As String = ""
Dim percentage As Integer = 0
Dim startdate As Date
Dim duedate As Date
Dim strtable As String = ""
Dim stritem As String = ""

_outlook = New Outlook.Application
nspace = _outlook.GetNamespace("MAPI")
taskFolder = nspace.GetDefaultFolder(13)
tasks = taskFolder.Items
NumItems = taskFolder.Items.Count

'if there are no tasks
If NumItems = 0 Then
stritem = "<tr><td>" & """Don't have any tasks.""" &
"</td></tr>"
Response.Write(stritem)
Else

For I = 1 To NumItems
strCategories = UCase(tasks(I).Categories.ToString)
If strCategories = "HOME" Then

strSubject = tasks(I).Subject
percentage = tasks(I).PercentComplete
startdate = tasks(I).StartDate
duedate = tasks(I).duedate
Response.Write(strSubject & "percent: " &
percentage.ToString & " " & FormatDateTime(startdate, vbGeneralDate) +
FormatDateTime(duedate, vbGeneralDate) + "<br>")

End If

Next
End If




_outlook.Quit()
_outlook = Nothing
tasks = Nothing
task = Nothing


End Sub

End Class
 
J

Jay B. Harlow [MVP - Outlook]

It seems that my local variables are not getting
the last value from Outlook and are keeping the old values.
To me it seems more like (sounds like) you have caching enabled on either
the page and/or your browser so ASP.NET or your browser is not bothering
having the page recreated.

Do you not see any tasks on your page, or do you only see tasks the first
time you go to the page.

How are you displaying the page? Normally Outlook will not work with the
ASPNET account, web pages normally run under the ASPNET account.

Hope this helps
Jay
 
O

outlook

Hi Jay, Thanks for replying. I am new on this and I'm getting kind of
desperate

This is what happens. I can retrieve those specific tasks from outlook
and display them into the browser. I use ASPNET account and
"imporsonate" in Web.Config file to be able to do this.

The problem is when I do some updates on any task in Outlook and I press
refresh on my browser, this doesn't display those new values. Then, when
I follow step by step my code, the variables are keeping those old
values and not the new ones.

THe part aI don't understand about your comment is about caching
enabled. What you mean with that?
Thanks
this is my code in aspx file:
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="frmtaks.aspx.vb" Inherits="tasks.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<SPAN class="DescriptionText">
<%gettasks() %>
</SPAN>
<form id="Form1" method="post" runat="server">
&nbsp;</form>
</body>
</HTML>
 
J

Jay B. Harlow [MVP - Outlook]

Outlook,
THe part aI don't understand about your comment is about caching
enabled. What you mean with that?
Caching is the ability within your browser and ASP.NET that will return the
last page displayed rather then recreate it.

Within your aspx you can use the OutputCache directive to enable it.

For details see (both):
http://msdn.microsoft.com/library/d...ry/en-us/cpguide/html/cpconaspoutputcache.asp

nntp:microsoft.public.dotnet.framework.aspnet.caching


As to your specific problem, I would not attempt to use Outlook from ASP.NET
(square hole, round peg). On the surface your code *should* work, however!

There are a plethora of other technologies within Exchange Server that are
intended to be used to display Exchange Server data (Outlook data) on a web
page. For a list of the majority of the technologies available to Exchange
Server see:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3/e2k3/_techsel_bytechnology.asp

Here are a handful of samples that may (or may not) help:

http://msdn.microsoft.com/library/d.../e2k3/e2k3/_exch2k_searching_folders_http.asp

http://msdn.microsoft.com/library/d.../e2k3/e2k3/_esdk_sending_a_message_webdav.asp

http://msdn.microsoft.com/library/d...k3/e2k3/_esdk_getting_mailbox_size_webdav.asp

http://msdn.microsoft.com/library/d...3/e2k3/_esdk_samples_exchmailnotify_intro.asp

Hope this helps
Jay



Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top