After reading all kinds of posts and using bits and pieces, I managed to get
something working to set a "Task".
But like others have posted, I can not get the "Reminder" to set in the task.
This code sends an email and a Task.
'======
Sub SendEmail()
Dim oOutlook As Object
Dim oMailItem As Object
Dim oRecipient As Object
Dim sRecipient As String
Dim oNameSpace As Object
Dim dDate As Date
dDate = TextBox8.Value
sRecipient = InputBox("Enter Your Email Address Here! (Example:
""richard.stanich"". " _
& "Do not add ""@aerodeisgnmfg.com"", it is automatically appended.")
sRecipient = LCase(sRecipient) & "@aerodesignmfg.com"
Set oOutlook = CreateObject("Outlook.Application")
Set oNameSpace = oOutlook.GetNamespace("MAPI")
oNameSpace.Logon , , True
Set oMailItem = oOutlook.CreateItem(0)
Set oRecipient = _
oMailItem.Recipients.Add(sRecipient)
oRecipient.Type = 1 '1 = To, use 2 for cc
'keep repeating these lines with
'your names, adding to the collection.
With oMailItem
.Subject = "This is an automatic email notification: CORRECTIVE
ACTION REQUEST (CAR)"
.Body = "You have been assigned CAR " & TextBox2.Value & ". " _
& "Please complete the CAR by " & TextBox8.Value & ". " _
& "The following link will take you to the folder containg
this CAR record." _
& " Q:\Qadocs\CORRECTIVE ACTIONS\" & sVar & " Correctice
Actions\" '& _
TextBox2.Value & ".xls"
'Add hyperlink above?
' .Attachments.Add ("filename") 'you only need this if
'you are sending attachments?
.Display 'use .Send when all testing done
'add outlook appointment 10.28.08
Dim myOlApp As Outlook.Application 'ERROR: user defined type not defined?
Dim myOlTask As Outlook.TaskItem
Set myOlApp = CreateObject("Outlook.Application")
Set myOlTask = myOlApp.CreateItem(olTaskItem)
With myOlTask
.Subject = "A CAR " & TextBox2.Value & " has been assigned to you,
due before " & TextBox8.Value
.Body = "You have been assigned CAR " & TextBox2.Value & ". " _
& "Please complete the CAR by " & TextBox8.Value & ". " _
& "The following link will take you to the folder containg
this CAR record." _
& " Q:\Qadocs\CORRECTIVE ACTIONS\" & sVar & " Correctice
Actions\"
.DueDate = dDate
.Importance = olImportanceHigh
.ReminderSet = True 'Not Setting Reminder?
.ReminderTime = dDate - 1 'Not being set?
.Recipients.Add (sRecipient)
.Assign
.Send
End With
Set myOlTask = Nothing
Set myOlApp = Nothing
'end 10.28.08
End With
Set oRecipient = Nothing
Set oMailItem = Nothing
Set oNameSpace = Nothing
Set oOutlook = Nothing
End Sub
'======
--
Regards
XP Pro
Office 2007