Create task in Outlook folder

J

JayDe

I am using Access 2007 to create tasks in Outlook 2007. That works fine
except for one thing. I cannot find the right keyword for folder or
subdirectory.

I have organized my tasks in different folder and want to put the tasks I am
creating in Access in the right folder.

Here is the testcode I am working with so far:

Sub MakeOutlookTask()

Dim OutlookApp As Outlook.Application
Dim OutlookTask As Outlook.TaskItem
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookTask = OutlookApp.CreateItem(olTaskItem)

With OutlookTask
.Subject = "Fjerde Oppgave"
.Body = "Dette er detaljene i oppgaven"
.ReminderSet = True
.ReminderTime = DateAdd("n", 2, Date)
.DueDate = DateAdd("n", 5, Date)
.Categories = "MerVerdi"
.ContactNames = "Geir Alexander Olderbakk."

Here I would like to put the folder

.Save

End With

Set OutlookApp = Nothing
Set OutlookTask = Nothing

End Sub
 
A

Alex Dybenko

Hi,
something like this.
Set myNamespace = objOutLook.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(13) 'olFolderTasks
Set otherFolder = myFolder.Folders("OtherTasks")

..Save 'I think you have to save item before moving it

OutlookTask.Move otherFolder

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 
J

JayDe

Thank you for the answer, but i am still having problems.

I think there must some problems in the declaration and creation of the
objects. Could you guid me thrue this also. This is what I tried.


Sub LagOutlookOppgave()

Dim OutlookApp As Outlook.Application
Dim OutlookTask As Outlook.TaskItem
Dim objOutLook, otherFolder, myFolder, myNamespace As Object

Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookTask = OutlookApp.CreateItem(olTaskItem)
Set myNamespace = objOutLook.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(13) 'olFolderTasks
Set otherFolder = myFolder.Folders("Sjekkliste")



With OutlookTask
.Subject = "Fjerde Oppgave laget av Jørn"
.Body = "Dette er detaljene i oppgaven"
.ReminderSet = True
.ReminderTime = DateAdd("n", 2, Date)
.DueDate = DateAdd("n", 5, Date)
.Categories = "MerVerdi"
.ContactNames = "Geir Alexander Olderbakk."
.Save
End With

OutlookTask.Move otherFolder

Set OutlookApp = Nothing
Set OutlookTask = Nothing

End Sub
 
A

Alex Dybenko

Hi,
looks ok, you only need to explicitly declare each var:

Dim objOutLook As Object, otherFolder As Object, myFolder As Object,
myNamespace As Object

are you getting any error?

Alex
 

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

Similar Threads


Top