Running multiple macros upon sending

Status
Not open for further replies.

Nix

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I'm surprised they don't work since they are two different functions, but they should combine easily enough. Do you want to send the category and flag to the recipient? if they are in the send macro, the setting you make are sent. if you do it when its added to the folder, only you see the category and flag.
 

Nix

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Hi,

I would just like them categorised and flagged for myself, not sent to the recipient. Although I would be interested to see the two different options if there is a need in the future to send.

Regards
Nikki

I'm surprised they don't work since they are two different functions, but they should combine easily enough. Do you want to send the category and flag to the recipient? if they are in the send macro, the setting you make are sent. if you do it when its added to the folder, only you see the category and flag.
 

Nix

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Instead of referencing ActiveInspector.CurrentItem use the Item variable that's passed to each of the procedures.
Hi,

Sorry I am not advanced enough to know what you mean by use the Item variable that's passed to each of the procedures. Is it possible to show me which parts of my marco needs to be changed?
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Forget what I wrote in the fist place. I focussed on the nonsense of the logic in the ItemSend event.

If you want the item be categorized only for you, then all you need to do is move the entire If block (that is from If... to End If...) from the ItemSend event to the ItemAdd event. Then delete the Set Item... line from that moved part, and the remaining ItemSend event can be deleted completely.
 

Hussein

New Member
Outlook version
Outlook 2010 64 bit
Email Account
POP3
Thanks for the explanation Michael, I was thinking move the entire If block (that is from If... to End If...) from the ItemSend event to the ItemAdd event could be a possibility, but i was not sure.
 
Status
Not open for further replies.
Top