Hello,
I'm completely new to VBA (and Outlook) - I've tried my hand at googling/searching through this forum and others but haven't been too lucky. If this is mentioned somewhere before, if you'd point me in the right direction that would be great.
What I would like to do is have the option to select 'yes/no' to a 'Would you like to add to 'non-default' calendar?' prompt, and be directed to the calendar if Yes, when sending or receiving emails (Outlook 2013). Note this is not for appointments, just normal messages. This way we can manage various deadlines for specific clients a bit easier.
I've been working from the code below, which lets me mark messages as task items. I've tried to adapt it but have been completely unsuccessful - eg. from 'If 'yes' then with item...', 'Mark as task... etc' does not seem to be at all interchangeable with . A nudge in the right direction would be great.
Thanks in advance
HTML Code:
Option Explicit
Private WithEvents olSentItems As Items
Private Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.Session
' instantiate objects declared WithEvents
Set olSentItems = objNS.GetDefaultFolder(olFolderSentMail).Items
Set objNS = Nothing
End Sub
Private Sub olSentItems_ItemAdd(ByVal Item As Object)
On Error Resume Next
Dim prompt As String
prompt$ = "Do you want to flag this message for followup?"
If MsgBox(prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Add flag?") = vbYes Then
With Item
.MarkAsTask olMarkThisWeek
' sets a due date in 3 days
.TaskDueDate = Now + 2
.ReminderSet = True
.ReminderTime = CDate(.TaskDueDate) & " " & TimeValue("13:00:00")
.Save
End With
End If
End Sub