G
Guest
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.
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.