Hi, I wonder whether someone may be able to help me please.
I've put together the following code which attaches a task to an email sent to multiple users.
The script works fine, but the problem I found when testing this, is that I don't have access to the Tasks for the majority of the recipients.
So I know that I need to approach this from a different perspective, so I've been looking to put together a script which converts the email to a Task once it has been received.
For the last 4 days I trawled through the internet to find a suitable example or tutorial which may show me how to do this, but the examples I've found either don't fit my requirements or I can't seem to get to, more down to my lack of knowledge than a script issue.
I just wondered whether someone may be able to look at this please and offer some guidance how I can convert this or even how I may start from scratch to produce a suitable script.
Many thanks and kind regards
I've put together the following code which attaches a task to an email sent to multiple users.
Code:
'****Create a task in users Tasks Development****
Public WithEvents myOlApp As Outlook.Application
Private Sub Application_Startup()
Initialize_handler
End Sub
Public Sub Initialize_handler()
Set myOlApp = CreateObject("Outlook.Application")
End Sub
Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim intRes As Integer
Dim strMsg As String
Dim objTask As TaskItem
Set objTask = Application.CreateItem(olTaskItem)
Dim strRecip As String
strMsg = "Do you want to create a task for this message?"
intRes = MsgBox(strMsg, vbYesNo + vbExclamation, "Create Task")
If intRes = vbNo Then
Cancel = False
Else
For Each recipient In Item.Recipients
strRecip = strRecip & vbCrLf & recipient.Address
Next recipient
With objTask
Set recpattern = .GetRecurrencePattern
recpattern.RecurrenceType = olRecursWeekly
recpattern.DayOfWeekMask = olMonday
recpattern.PatternStartDate = #11/25/2013 9:00:00 AM#
recpattern.Interval = 1
' .Body = strRecip & vbCrLf & Item.Body
.Body = Item.Body
.Subject = Item.Subject
.Save
End With
Cancel = False
End If
Set objTask = Nothing
End Sub
The script works fine, but the problem I found when testing this, is that I don't have access to the Tasks for the majority of the recipients.
So I know that I need to approach this from a different perspective, so I've been looking to put together a script which converts the email to a Task once it has been received.
For the last 4 days I trawled through the internet to find a suitable example or tutorial which may show me how to do this, but the examples I've found either don't fit my requirements or I can't seem to get to, more down to my lack of knowledge than a script issue.
I just wondered whether someone may be able to look at this please and offer some guidance how I can convert this or even how I may start from scratch to produce a suitable script.
Many thanks and kind regards