none
Exchange Outlook 365 VBA set reminder when sending mails does not work (it did in Outlook 2007 and local Exchange Server) RRS feed

  • Question

  • Hello,

    we have now Outlook 365. When we had Outlook 2007 the code below worked witout error when sending emails. I cannot find a solution with search engines. What happens:

    I have a rule that copies sent emails to my inbox. When a mail appears in the inbox, an event fires. The code sets a reminder 7 days in the future. The strange thing is, that the corresponding "bell" appears in the inbox but disappears within a second! (Something removes the reminder!?)

    'Modul ThisOutlookSession
    
    Private WithEvents Items As Outlook.Items
    
    Private Sub Application_Startup()
      Dim Ns As Outlook.NameSpace
    
      Set Ns = Application.GetNamespace("MAPI")
      Set Items = Ns.GetDefaultFolder(olFolderInbox).Items  
    End Sub
    
    
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
      Dim dt As Date
      Dim tm As String
      Dim mark
    
              dt = DateAdd("d", 7, Date) 'reminder in 7 days
              mark = olMarkNextWeek
              tm = CStr(dt) & " 08:00" 'at 8:00 a.m.
    
            Item.FlagDueBy = tm 'Date and Time due
            Item.ToDoTaskOrdinal = tm   'task
            'Item.MarkAsTask mark    '(does not work with "drafts", worked with Outlook 2007)
            Item.TaskStartDate = dt 'Start date
            Item.TaskDueDate = dt 'Due date
            Item.ReminderSet = True
            Item.UnRead = False 'mark Mail as read
            Item.ReminderTime = tm  'reminder
            Item.Save   'save new settings ==> The reminder "bell" appears but disappears again.
      
      dt = 0
      tm = ""
      mark = ""
      Set Item = Nothing
    
    End Sub

    How can I keep the reminder the code set?

    Additionally:
    If I use Item.MarkAsTask I get now:
     "runtime error -2147467263 (800004001). Drafts cannot be marked. MarkasTask is only valid for elements sent or received."

    This worked with Outlook 2007, why not with 365/2019?

    I posted the problem in a german speaking Forum, but did not get an answer. It would be helpful if somebody could reproduce the behaviour.

    thank you

    arno

    Wednesday, September 25, 2019 2:55 PM

All replies

  • Can anybody reproduce the problem?
    Monday, September 30, 2019 4:44 PM
  • Hello,

    there is a workaround or a 50% solution that sets a reminder, however, the email is not marked as a task.

    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
      Dim dt As Date
      Dim tm As String
      Dim mark
    
              dt = DateAdd("d", 7, Date) 'Erinnerung in 7 Tagen
              mark = olMarkNextWeek
              tm = CStr(dt) & " 08:00" 'um 8:00 Uhr
    
            'this works:
            Item.TaskStartDate = dt 'Start date
            Item.TaskDueDate = dt 'Due date
            Item.ReminderTime = tm  'reminder
            Item.ReminderSet = True
    
      dt = 0
      tm = ""
      mark = ""
      Set Item = Nothing
      Set Ns = Nothing
    End Sub

    It would be very nice, if someone could figure out how to mark the email as a task after sending. (It is no problem when I select an email in the inbox and run the similar code, it will be marked as task. It just does not work when sending the emai.)

    regards

    arno

    Wednesday, October 2, 2019 3:24 PM