473,473 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Outlook Task Snag

I am trying to progamatically create tasks in Outlook using VB.Net. I am
using the following code:
****
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olTaskItem As Outlook.TaskItem
Dim strbodyText As String
olApp = CreateObject("Outlook.Application")
olNS = olApp.GetNamespace("MAPI")
olFolder = olNS.GetDefaultFolder(olFolderTasks)
olTaskItem = olFolder.Items.Add("IPM.Task")
With olTaskItem
.Subject = "Rural Inspections "
.ReminderTime = "2:00:00 PM"
.ReminderSet = True
.Categories = "Rural Projects"
.Save()
End With
olTaskItem = Nothing
olFolder = Nothing
olNS = Nothing
olApp = Nothing
End Sub
****
VB tells me that "Name 'olFolderTasks' is not declared" Line 52.
I'm not sure what else to do to declare this variable. Should I delclare it
with "Dim" like the others above? If so suppose it would be something like:
Dim olFolderTasks As Outlook.??????
I'm pretty new to VB so sorry if this is a basic question.

Also, I would like to put the date on the subject line. In Excel I can use:
..Subject = "Rural Inspections " & Date$
but VB won't allow Date$, Date, or Date() here.

Thanks in advance.
Nov 21 '05 #1
4 4160
try 'Outlook.OlDefaultFolders.olFolderTasks' and 'Today' for todays
date.

On Thu, 21 Apr 2005 06:28:01 -0700, "digger27"
<di******@discussions.microsoft.com> wrote:
I am trying to progamatically create tasks in Outlook using VB.Net. I am
using the following code:
****
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olTaskItem As Outlook.TaskItem
Dim strbodyText As String
olApp = CreateObject("Outlook.Application")
olNS = olApp.GetNamespace("MAPI")
olFolder = olNS.GetDefaultFolder(olFolderTasks)
olTaskItem = olFolder.Items.Add("IPM.Task")
With olTaskItem
.Subject = "Rural Inspections "
.ReminderTime = "2:00:00 PM"
.ReminderSet = True
.Categories = "Rural Projects"
.Save()
End With
olTaskItem = Nothing
olFolder = Nothing
olNS = Nothing
olApp = Nothing
End Sub
****
VB tells me that "Name 'olFolderTasks' is not declared" Line 52.
I'm not sure what else to do to declare this variable. Should I delclare it
with "Dim" like the others above? If so suppose it would be something like:
Dim olFolderTasks As Outlook.??????
I'm pretty new to VB so sorry if this is a basic question.

Also, I would like to put the date on the subject line. In Excel I can use:
.Subject = "Rural Inspections " & Date$
but VB won't allow Date$, Date, or Date() here.

Thanks in advance.


Nov 21 '05 #2
Tosch,
Outlook.OlDefaultFolders.olFolderTasks show up as not being defined. If I
remove the .olFolderTasks and put quotes around the olFolderTasks to make the
line look like this:
olFolder = olNS.GetDefaultFolder("olFolderTasks")
I get the following error:
An unhandled exception of type 'System.InvalidCastException' occurred in
microsoft.visualbasic.dll
Additional information: Cast from string "olFolderTasks" to type 'Integer'
is not valid.

The line that is highlited is
olFolder = olNS.GetDefaultFolder("olFolderTasks")

Any ideas?
"Tosch" wrote:
try 'Outlook.OlDefaultFolders.olFolderTasks' and 'Today' for todays
date.

On Thu, 21 Apr 2005 06:28:01 -0700, "digger27"
<di******@discussions.microsoft.com> wrote:
I am trying to progamatically create tasks in Outlook using VB.Net. I am
using the following code:
****
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olTaskItem As Outlook.TaskItem
Dim strbodyText As String
olApp = CreateObject("Outlook.Application")
olNS = olApp.GetNamespace("MAPI")
olFolder = olNS.GetDefaultFolder(olFolderTasks)
olTaskItem = olFolder.Items.Add("IPM.Task")
With olTaskItem
.Subject = "Rural Inspections "
.ReminderTime = "2:00:00 PM"
.ReminderSet = True
.Categories = "Rural Projects"
.Save()
End With
olTaskItem = Nothing
olFolder = Nothing
olNS = Nothing
olApp = Nothing
End Sub
****
VB tells me that "Name 'olFolderTasks' is not declared" Line 52.
I'm not sure what else to do to declare this variable. Should I delclare it
with "Dim" like the others above? If so suppose it would be something like:
Dim olFolderTasks As Outlook.??????
I'm pretty new to VB so sorry if this is a basic question.

Also, I would like to put the date on the subject line. In Excel I can use:
.Subject = "Rural Inspections " & Date$
but VB won't allow Date$, Date, or Date() here.

Thanks in advance.


Nov 21 '05 #3
Try this:

olFolder =
olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderTasks)
On Thu, 21 Apr 2005 07:47:04 -0700, "digger27"
<di******@discussions.microsoft.com> wrote:
Tosch,
Outlook.OlDefaultFolders.olFolderTasks show up as not being defined. If I
remove the .olFolderTasks and put quotes around the olFolderTasks to make the
line look like this:
olFolder = olNS.GetDefaultFolder("olFolderTasks")
I get the following error:
An unhandled exception of type 'System.InvalidCastException' occurred in
microsoft.visualbasic.dll
Additional information: Cast from string "olFolderTasks" to type 'Integer'
is not valid.

The line that is highlited is
olFolder = olNS.GetDefaultFolder("olFolderTasks")

Any ideas?
"Tosch" wrote:
try 'Outlook.OlDefaultFolders.olFolderTasks' and 'Today' for todays
date.

On Thu, 21 Apr 2005 06:28:01 -0700, "digger27"
<di******@discussions.microsoft.com> wrote:
>I am trying to progamatically create tasks in Outlook using VB.Net. I am
>using the following code:
>****
>Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles MyBase.Load
> Dim olApp As Outlook.Application
> Dim olNS As Outlook.NameSpace
> Dim olFolder As Outlook.MAPIFolder
> Dim olTaskItem As Outlook.TaskItem
> Dim strbodyText As String
> olApp = CreateObject("Outlook.Application")
> olNS = olApp.GetNamespace("MAPI")
> olFolder = olNS.GetDefaultFolder(olFolderTasks)
> olTaskItem = olFolder.Items.Add("IPM.Task")
> With olTaskItem
> .Subject = "Rural Inspections "
> .ReminderTime = "2:00:00 PM"
> .ReminderSet = True
> .Categories = "Rural Projects"
> .Save()
> End With
> olTaskItem = Nothing
> olFolder = Nothing
> olNS = Nothing
> olApp = Nothing
> End Sub
>****
>VB tells me that "Name 'olFolderTasks' is not declared" Line 52.
>I'm not sure what else to do to declare this variable. Should I delclare it
>with "Dim" like the others above? If so suppose it would be something like:
>Dim olFolderTasks As Outlook.??????
>I'm pretty new to VB so sorry if this is a basic question.
>
>Also, I would like to put the date on the subject line. In Excel I can use:
>.Subject = "Rural Inspections " & Date$
>but VB won't allow Date$, Date, or Date() here.
>
>Thanks in advance.



Nov 21 '05 #4
OK, so the code that finally worked is below. Note change in line 10 . No
need to declare "olFolderTasks". Still have one more problem. I want to
attach an excel document to the task. Using .Attachments.Add = <filepath>
does not work. I get:

Argument not specified for parameter 'Source' of 'Public Overridable
Function Add(Source As Object, [Type As Object], [Position As Object],
[DisplayName As Object]) As Outlook.Attachment'.

NO idea what that means.

Any ideas?
****
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olTaskItem As Outlook.TaskItem
Dim strbodyText As String
olApp = CreateObject("Outlook.Application")
olNS = olApp.GetNamespace("MAPI")
olFolder =
olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderTasks)
olTaskItem = olFolder.Items.Add("IPM.Task")
With olTaskItem
.Subject = "Rural Inspections "
.DueDate = Today
.ReminderTime = Now
.ReminderSet = True
.Categories = "Rural Projects"
.Save()
End With
olTaskItem = Nothing
olFolder = Nothing
olNS = Nothing
olApp = Nothing
Me.Close()
End Sub
End Class
****

"digger27" wrote:
Tosch,
Outlook.OlDefaultFolders.olFolderTasks show up as not being defined. If I
remove the .olFolderTasks and put quotes around the olFolderTasks to make the
line look like this:
olFolder = olNS.GetDefaultFolder("olFolderTasks")
I get the following error:
An unhandled exception of type 'System.InvalidCastException' occurred in
microsoft.visualbasic.dll
Additional information: Cast from string "olFolderTasks" to type 'Integer'
is not valid.

The line that is highlited is
olFolder = olNS.GetDefaultFolder("olFolderTasks")

Any ideas?
"Tosch" wrote:
try 'Outlook.OlDefaultFolders.olFolderTasks' and 'Today' for todays
date.

On Thu, 21 Apr 2005 06:28:01 -0700, "digger27"
<di******@discussions.microsoft.com> wrote:
I am trying to progamatically create tasks in Outlook using VB.Net. I am
using the following code:
****
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olTaskItem As Outlook.TaskItem
Dim strbodyText As String
olApp = CreateObject("Outlook.Application")
olNS = olApp.GetNamespace("MAPI")
olFolder = olNS.GetDefaultFolder(olFolderTasks)
olTaskItem = olFolder.Items.Add("IPM.Task")
With olTaskItem
.Subject = "Rural Inspections "
.ReminderTime = "2:00:00 PM"
.ReminderSet = True
.Categories = "Rural Projects"
.Save()
End With
olTaskItem = Nothing
olFolder = Nothing
olNS = Nothing
olApp = Nothing
End Sub
****
VB tells me that "Name 'olFolderTasks' is not declared" Line 52.
I'm not sure what else to do to declare this variable. Should I delclare it
with "Dim" like the others above? If so suppose it would be something like:
Dim olFolderTasks As Outlook.??????
I'm pretty new to VB so sorry if this is a basic question.

Also, I would like to put the date on the subject line. In Excel I can use:
.Subject = "Rural Inspections " & Date$
but VB won't allow Date$, Date, or Date() here.

Thanks in advance.


Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Boris Tabenkin | last post by:
Hi all, I want to apologize if this is the wrong forum for this question. I would like to write an application, in Java running on UNIX, that would insert, read, and mark as completed tasks in...
0
by: William | last post by:
Hi there, Is there anybody here who ever create outlook task item from asp .net script successfully ? Actually I've created the script for creating the task, and it run successfully from the...
0
by: DC | last post by:
I have a requirement for an application that, through drag and drop, takes the email attachments from Outlook 2000 desktop clients and sends them in binary format to a SQL Server database. At this...
9
by: George McCullen | last post by:
I have an Outlook 2003 using Exchange Server 2003 Public Contacts Folder containing 20,000 Contacts. I am writing a VB .Net 2003 program that loops through all the contacts in a "for each oCt in...
1
by: Jason L James | last post by:
Hi All, does anyone have the sequence of commands to add a new task to an outlook task list using the outlook Object Model. I've tried a few things but I can't ssem to get it quite right. ...
5
by: Imry | last post by:
Is there a way to programatically add items to the outlook task list using VB ..net?
11
by: rayala | last post by:
Hi all, I am having very weird problem in my Outlook I am running my web application from with in Outlook.I found a strange problem that it is creating different sessionId if i open a new...
5
by: rdemyan via AccessMonster.com | last post by:
I would like to have my application add administrative tasks to an Administrator's Outlook Task Folder. I know how to get the User group of the CurrentUser and think I can even code how to do the...
3
by: mwolowski | last post by:
Hello, I'd like to add tasks, appointments, etc using c# to outlook For example i added reference using OutLook = Microsoft.Office.Interop.Outlook; and the code: 1. ---------------------...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.