VBA Recurring Task Converted From Email

IRHM73

Member
Outlook version
Email Account
POP3
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.

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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
The only way you can add a task to someone's task list is if you are both on the same exchange server and are give the correct permissions.

You can convert email you receive to tasks but can't create tasks for others. They'd need to set up the VBA themselves, to use something like this code.

You can create a task and insert it in an email - they'll need to save it to their own tasks folder.
 

IRHM73

Member
Outlook version
Email Account
POP3
Hi Diane, thank you very much for coming back to me with this, and for the confirmation and what is and isn't possible.

It looks like I'll have to have a think about this a little more.

Kind Regards
 
Top