Need help with assigning a task in Outlook from Access

unixkid

New member
Local time
Today, 14:53
Joined
Dec 14, 2010
Messages
7
need some help with assigning a task in Outlook using Acess.
I want to have the option to be able to assign a task to yourself, however, this cannot be achieved using .assign and .send, therefore I made a table in which all the user information is stored (name and email address)
and then if the user name (which I get usign the environ "username" method) is found within the email address then it does not use the assign method, just the send, and vice versa as you'll see below.
The problem I have is that when it assigns to another user, it sends the email for the task however it enters the persons email address in twice, which then means that I cannot keep track of the changes! Please help!!!

Option Compare Database
Private Sub Task_Click()
On Error GoTo Err_Task_Click

Dim OutlookApp As Outlook.Application
Dim OutlookTask As Outlook.TaskItem

Dim db As Database
Dim Lrs As DAO.Recordset
Dim LSQL As String
Dim LDescription As String
Set db = CurrentDb()
LSQL = "select Description from Correspondence"
Set Lrs = db.OpenRecordset(LSQL)
If Lrs.EOF = False Then
LDescription = Lrs("Description")
Else
LDescription = "Not found"
End If
Lrs.Close
Set Lrs = Nothing

Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookTask = OutlookApp.CreateItem(olTaskItem)
Set myDelegate = OutlookTask.Recipients.Add(Me.Combo16.Column(2))
OutlookTask.Subject = Forms![Tracker]![Description]
OutlookTask.Body = "Tracker Notes:" & " " & Forms![Tracker]![Notes] & Chr(13) & "Tracker ID:" & " " & Forms![Tracker]![ID] & Chr(13) _
& "Reference:" & " " & Forms![Tracker]![Reference] & Chr(13) & Chr(13) & "Path:" & " " & Forms![Tracker]![Path] & Chr(13) _
& Chr(13) & Chr(13) & "Additional Notes: " & Text0.Value
OutlookTask.ReminderSet = True
OutlookTask.ReminderTime = DateAdd("n", 1, Now)
OutlookTask.DueDate = Text2.Value
OutlookTask.ReminderPlaySound = True
OutlookTask.ReminderSoundFile = "C:\Windows\Media\Ding.wav"

If InStr(UCase(OutlookTask.Recipients.Add(Me.Combo16.Column(2))), UCase(Environ("username"))) = 1 Then
OutlookTask.Save
Else
OutlookTask.Assign
OutlookTask.Send
End If

Exit_Task_Click:
Exit Sub
Err_Task_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err = ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_Task_Click

End Sub
 
unixkid, try this. It gets the data from the form. Code is for MS 2007

Code:
Function fncAddOutlookTask()
    Dim strAnsDate As String
    Dim strAnsTime As String
     Dim OutlookApp As Outlook.Application
     Dim OutlookTask As Outlook.TaskItem
    strAnsDate = Forms!frmShowAddOutlookTask!txtReminderDate '- 40
    strAnsTime = Forms!frmShowAddOutlookTask!txtReminderTime
     Set OutlookApp = CreateObject("Outlook.Application")
     Set OutlookTask = OutlookApp.CreateItem(olTaskItem)
    
     With OutlookTask
         .Subject = Forms!frmShowAddOutlookTask!OLSubject
         .Body = Forms!frmShowAddOutlookTask!OLNotes
         .ReminderSet = Forms!frmShowAddOutlookTask!OLReminderONOff
         
        
         .StartDate = Forms!frmShowAddOutlookTask!OLStartDate
         
         'MsgBox (CDbl(.ReminderTime))
         .DueDate = Forms!frmShowAddOutlookTask!OLDueDate
          '.ReminderTime = DateAdd("d", -5, "11-20-2010") 'Forms!frmShowAddOutlookTask!RememberTime)
         .ReminderTime = Format(strAnsDate, "short date") & " " & Format(strAnsTime, "short time")
         .PercentComplete = 10
         .Categories = Forms!frmShowAddOutlookTask!OLCategories
         .Companies = Forms!frmShowAddOutlookTask!OLCompanies
         
         .Status = Forms!frmShowAddOutlookTask!txtPriority
         
         .Importance = Forms!frmShowAddOutlookTask!txtStatus
         
         .Save
     End With
 End Function

Richard
 
unixkid, try this. It gets the data from the form. Code is for MS 2007

Code:
Function fncAddOutlookTask()
    Dim strAnsDate As String
    Dim strAnsTime As String
     Dim OutlookApp As Outlook.Application
     Dim OutlookTask As Outlook.TaskItem
    strAnsDate = Forms!frmShowAddOutlookTask!txtReminderDate '- 40
    strAnsTime = Forms!frmShowAddOutlookTask!txtReminderTime
     Set OutlookApp = CreateObject("Outlook.Application")
     Set OutlookTask = OutlookApp.CreateItem(olTaskItem)
    
     With OutlookTask
         .Subject = Forms!frmShowAddOutlookTask!OLSubject
         .Body = Forms!frmShowAddOutlookTask!OLNotes
         .ReminderSet = Forms!frmShowAddOutlookTask!OLReminderONOff
         
        
         .StartDate = Forms!frmShowAddOutlookTask!OLStartDate
         
         'MsgBox (CDbl(.ReminderTime))
         .DueDate = Forms!frmShowAddOutlookTask!OLDueDate
          '.ReminderTime = DateAdd("d", -5, "11-20-2010") 'Forms!frmShowAddOutlookTask!RememberTime)
         .ReminderTime = Format(strAnsDate, "short date") & " " & Format(strAnsTime, "short time")
         .PercentComplete = 10
         .Categories = Forms!frmShowAddOutlookTask!OLCategories
         .Companies = Forms!frmShowAddOutlookTask!OLCompanies
         
         .Status = Forms!frmShowAddOutlookTask!txtPriority
         
         .Importance = Forms!frmShowAddOutlookTask!txtStatus
         
         .Save
     End With
 End Function

Richard

ah i guess it doesn't help im using access 2003 :( would this work on that?
 
It should, it worked in MS 2000 database running in 2007 but you have to have the correct references.

Good luck.

Richard
 
It should, it worked in MS 2000 database running in 2007 but you have to have the correct references.

Good luck.

Richard

hmm but you don't use the .send function, how will it be able to set a task on another users outlook?
 
My problem was setting a task in my Outlook not another user.
 

Users who are viewing this thread

Back
Top Bottom