Hi,
I have the macros below that work perfectly on their own, but I want to combine them so both of them run when sending. I have tried just pasting them both but then none of them work.
Also I have only tested them working fine individually on New emails. Do I need to adjust anything for them to work on forwards and replies as well (but for the category one I would only want it to ask for a category if it didn't already have one)
This one asks if I want to Flag the message after sending
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 + 3
.ReminderSet = True
.ReminderTime = Now + 2
.Save
End With
End If
End Sub
This one brings up the Category box for me to choose a category
'Categorize Sent Items
'Place in ThisOutlookSession
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeOf Item Is Outlook.MailItem And Len(Item.Categories) = 0 Then
Set Item = Application.ActiveInspector.CurrentItem
Item.ShowCategoriesDialog
End If
End Sub
I have the macros below that work perfectly on their own, but I want to combine them so both of them run when sending. I have tried just pasting them both but then none of them work.
Also I have only tested them working fine individually on New emails. Do I need to adjust anything for them to work on forwards and replies as well (but for the category one I would only want it to ask for a category if it didn't already have one)
This one asks if I want to Flag the message after sending
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 + 3
.ReminderSet = True
.ReminderTime = Now + 2
.Save
End With
End If
End Sub
This one brings up the Category box for me to choose a category
'Categorize Sent Items
'Place in ThisOutlookSession
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeOf Item Is Outlook.MailItem And Len(Item.Categories) = 0 Then
Set Item = Application.ActiveInspector.CurrentItem
Item.ShowCategoriesDialog
End If
End Sub