Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2004
    Posts
    6

    Unhappy Unanswered: Using Access To Send An Outlook Task

    Hi!

    I'm building a database that tracks various documentation updates and I need to be able to send an Outlook task so that the recipient will know that they have been assigned a new document in the database to update. Here's the code that I have so far:

    Private Sub cmdSend_Click()
    Dim NowDate As Date
    Dim DateEnd As Date
    Dim DateDif As Long
    Dim Task As Object

    Set Task = Outlook.CreateItem(olTaskItem)
    NowDate = Now()
    DateEnd = DateDue.Value

    If DateAdd("d", -1, DateEnd) >= 1 Then
    DateEnd = DateAdd("d", -1, DateEnd)
    Else
    End If

    Task.Assign
    Task.Subject = "You have been assigned task " & ConfirmationID.Value
    Task.Body = "Please check the Task database for more information."
    Task.DueDate = DateEnd
    Task.Importance = (olImportanceHigh)
    Task.ReminderSet = True
    Task.Save
    Task.Send

    End Sub

    The problem I am having is how/where to put the information regarding the recipient of the task. The code creates a task and allows is to be assigned, but I can't get it to insert an email address for a TO statement.

    HELP!!!!

    Thanks so much,

    E

  2. #2
    Join Date
    Nov 2004
    Posts
    6

    Smile Got It!!!

    In case anyone is interested in how I fixed the problem. Here's the code. Couldn't have done it without all the wonderful help on the forum. THanks!

    Dim NowDate As Date
    Dim DateEnd As Date
    Dim DateDif As Long
    Dim Task As Object
    Dim ToContact As Object

    Set Task = Outlook.CreateItem(olTaskItem)
    NowDate = Now()
    DateEnd = DateDue.Value

    If DateAdd("d", -1, DateEnd) >= 1 Then
    DateEnd = DateAdd("d", -1, DateEnd)
    Else
    End If

    Task.Subject = "You have been assigned task " & ConfirmationID.Value
    Task.Body = "Please check the CASC Task database for more information."
    Task.Assign
    Set ToContact = Task.Recipients.Add("someone@somewhere.com")
    Task.DueDate = DateEnd
    Task.Importance = (olImportanceHigh)
    Task.ReminderSet = True
    Task.Save
    Task.Send

  3. #3
    Join Date
    Jan 2004
    Location
    California, USA
    Posts
    25

    Using Access To Send An Outlook Task

    Interesting topic. Just happens that I'm working on that too, but a slightly different problem. I'm picking information off of a subform to make my message and provide the receprient's name. The receprient's email address is in a string.
    http://www.access-programmers.co.uk/...ad.php?t=79767
    ==================================
    Public Function AssignTask()
    Dim myOlApp As New Outlook.Application
    Dim myItem As Outlook.Outlook.TaskRequestItem
    Dim myDelegate As Outlook.Recipient
    'Information from subform
    Dim strReciprient As String, strResponsibleParty As String 'These are the same person
    Dim strProject As String 'ActionDescription
    Dim strFacility As String
    Dim strFrequency As String
    Dim strDueDate As String
    Dim frm As Form
    Dim sfN As Form 'Program Notification SubForm

    Set frm = Forms!frmMainEntry.Form
    Set sfN = frm.[fctlNotifications].Form
    If sfN.[ProgramID] = sfN.[txtID] Then

    strProject = sfN.ProgramDescription
    strFacility = sfN.Facility
    strDueDate = sfN.DueDate
    strFrequency = sfN.FrequencyOfService
    strReciprient = sfN.EmailAddress
    strResponsibleParty = sfN.ResponsibleParty
    strSender = frm!txtWelcome
    Else
    Exit Function
    End If

    Set myOlApp = CreateObject("Outlook.Application")
    Set myItem = myOlApp.CreateItem(olTaskItem)

    myItem.Assign
    Set myDelegate = myItem.Recipients.Add(strReciprient)
    myDelegate.Resolve
    If myDelegate.Resolved Then
    myItem.Subject = "Notification Of Compliance Requirement"
    myItem.Body = vbCrLf & vbCrLf & vbCrLf & _
    "To: " & strResponsibleParty & vbCrLf & vbCrLf & vbCrLf & _
    "This is to notify you that the requirement for " & strProject & " at the " & _
    strFacility & " is due on " & strDueDate & "." & vbCrLf & _
    strProject & " is required " & strFrequency & "." & vbCrLf & vbCrLf & vbCrLf & _
    "Keep On Track With Safety" & vbCrLf & strSender
    myItem.DueDate = strDueDate
    myItem.ReminderTime = DateAdd("ww", -1, strDueDate) 'Remind 1 Week before Due Date.
    'myItem.Display
    myItem. Importance = (olImportanceHigh)
    myItem.Send
    End If
    End Function
    ==================================
    MS Knowledge base
    http://msdn.microsoft.com/library/de...HV05247533.asp
    http://support.microsoft.com/default...b;en-us;209932

    How do I use a variable for an e-mail address?

    Thanks,
    PC

  4. #4
    Join Date
    Oct 2006
    Posts
    1
    I'm trying to do something similar only I want the body of the task pulled from a text box on my form. How can I accomplish this?

  5. #5
    Join Date
    Dec 2008
    Posts
    1
    .body = [Form_yourformname].[Yourtextboxname].value

    or

    .body = Me.[Yourtextboxname].value

    Does that help?

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Man, sweet bump. I think this problem is well and truly done ^^
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  7. #7
    Join Date
    Dec 2012
    Posts
    28
    Hi,
    I have been trying to use this code but no luck on what I want it to do exactly.

    Is it possible to check a due date and then send out an email x number of days before that due date with a few fields from the form? For example, email a customer name, customer #, and due date?

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •