access to outlook (1 Viewer)

cvboas

Registered User.
Local time
Yesterday, 22:39
Joined
Jul 31, 2006
Messages
20
Hi.
I'm new in the vb code processing.
I want to connect my database to outlook to add tasks, but i whant to be the user to determine the regularity of the task. That is possivel?
Thank you.

the code i have is


Private Sub AddOutLookTask_Click()

Dim appOutLook As Outlook.Application
Dim taskOutLook As Outlook.TaskItem
Dim hora_aviso As Date
Set appOutLook = CreateObject("Outlook.Application")
Set taskOutLook = appOutLook.CreateItem(olTaskItem)
With taskOutLook
cod_cliente = codcliente
.Subject = "Visita programada para a empresa: " & codcliente.Column(1)
.Body = " NÃO ESQUCER DE ALTERAR A PERIODICIDADE (Ctrl+b)"
.ReminderSet = True
.ReminderTime = DateAdd("n", 1, data_inicio) + #9:15:00 AM# ' Set to remind us 1
' minutes from now.
.DueDate = DateAdd("n", 1, data_inicio) + #9:15:00 AM# ' Set the due date to
' 1 minutes from now.
.ReminderPlaySound = True
'add the path to a .wav file on your computer.
.ReminderSoundFile = "C:\WINDOWS\Media\notify.wav"
.Save
End With
End Sub
 

bonekrusher

Registered User.
Local time
Yesterday, 22:39
Joined
Nov 19, 2005
Messages
266
This is what I use to add a reminder. Its similiar if you want to add a task:
I think you need to change

Code:
Dim objappt as objOutlook.CreateItem(olAppointmentItem) 

Set objAppt = objOutlook.CreateItem(olAppointmentItem)

to

Code:
Dim objappt as objOutlook.CreateItem(olTaskItem) 

Set objAppt = objOutlook.CreateItem(olTaskItem)






Code:
Private Sub addReminder_Click()
On Error GoTo Err_addReminder_Click
If MsgBox("Are you sure you want to add this reminder to your Outlook Calendar? (Max 21 days)", vbYesNo, "Add Reminder") = vbNo Then End
 

Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Dim dayz As Integer
Dim total As Integer
Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)
dayz = InputBox("How many days notice do you want? (Max 21 days)")
total = dayz * 1440
With objAppt
.start = Me!res & " " & Me!cboStartTime 'change this to Date and time - mine is from a combo boxes
.Subject = "Reminder -Audit Number " 
.Duration = 0
.ReminderSet = True
.ReminderMinutesBeforeStart = total
.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing


'Release the Outlook object variable.
Set objOutlook = Nothing

'Set the AddedToOutlook flag, save the record, display a message.
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"

Exit Sub

Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
Exit_addReminder_Click:
    Exit Sub

Err_addReminder_Click:
    MsgBox Err.Description
    Resume Exit_addReminder_Click
End Sub
 

dsfcom

Registered User.
Local time
Today, 01:39
Joined
Mar 13, 2007
Messages
72
Post Task to Public Folder/More Options?

I would like to use some of this code and pretty much understand most of the workings but would like to post the task to a public folder instead of my profile tasks folder. How would I do this? Also, are there more options I can set such as STATUS etc.?
 

dsfcom

Registered User.
Local time
Today, 01:39
Joined
Mar 13, 2007
Messages
72
Ok. I've figured out the STATUS and other options. Just need to figure out how to post to a public folder using a custom form.
 

dsfcom

Registered User.
Local time
Today, 01:39
Joined
Mar 13, 2007
Messages
72
Figured it out...

If you need to post a task to a public folder on an exchange server (and not your default profile folder) you'll need to find out your folder's EntryID and StoreID then use the following code (or edit as needed); also allows custom form usage:

Code:
    Dim txtEntryID
    Dim txtStoreID
    Dim txtFormName
            
    'Retrive task folder EntryID and StoreID
    txtFormName = "Task"
    txtEntryID = DLookup("[EntryID]", "YourTable", "YourRef")
    txtStoreID = DLookup("[StoreID]", "YourTable", "YourRef")

        'Open Outlook
        Set ol = CreateObject("Outlook.Application")
        Set olns = ol.GetNamespace("MAPI")
        
        'Select task management folder
        Set myFolder = olns.GetFolderFromID(txtEntryID, txtStoreID)
        
        'Create task with Munitions Task form
        Set myItem = myFolder.Items.Add("IPM.Task." & txtFormName)
    
            'Save Task with information previously retrieved
            With myItem
                .Subject = Me.TASKDESC
                .STARTDATE = Me.ESTDATESTART
                .Save
            End With
 

Users who are viewing this thread

Top Bottom