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.
Similar threads
Thread starter Title Forum Replies Date
G Running multiple sessions of Outlook Using Outlook 2
N contact notepad 'style' getting changed after clicking and running Activities Using Outlook 2
Bri the Tech Guy Run Script rule not running for newly arriving messages Outlook VBA and Custom Forms 25
S Problem running Command button code Outlook VBA and Custom Forms 2
B Automation error running VB macro code Outlook VBA and Custom Forms 8
Diane Poremsky OUTLOOK.EXE continues running after you exit Outlook New Slipstick.com Articles 0
Diane Poremsky Running Outlook Macros on a Schedule New Slipstick.com Articles 0
B ActiveExplorer return NULL on new Window user login and running Outlook first time Using Outlook 1
JorgeDario Template oft that contains VBScript Is not running Using Outlook 1
M Mark Complete keyboard shortcut... on a mac running Windows Bootcamp Using Outlook 0
N Outlook 2007 To-Do-List status keeps running Using Outlook 2
S The attempted operation failed ... 2nd time running code Outlook VBA and Custom Forms 3
G email returns after running macro to move emails Outlook VBA and Custom Forms 1
P Outlook Macro keeps running for the same messagage Using Outlook 2
M Accessing BCM with Excel / Running Reports BCM (Business Contact Manager) 1
G Error when running scanpst.exe Using Outlook 1
V Running scripts with Outlook 2013 Using Outlook 17
D Stopping "do you want to continue running scripts on this page" warnings Using Outlook 4
M Running macros in tasks sent out as meeting requests in invitees machine Using Outlook 4
N Rules stop running automatically Using Outlook 10
D VBA code running on Server? Shared mailbox email routing Using Outlook 3
T WAB editing: To help prevent malicious code from running.......... Using Outlook 18
M Outlook.exe 1.2Gb memory usage if running certain BCM reports BCM (Business Contact Manager) 8
M Why rules stop running automatically? Using Outlook 1
V Trouble Running Outlook 2007 and 2010 Using Outlook 4
S CSCANPST To Automate Running SCANPST.EXE Using Outlook 1
L remove a hotmail account from Outlook 2007 running on Vista home premium Using Outlook.com accounts in Outlook 1
S Outlook 2007 Running on Windows 7 hangs on send Using Outlook 7
P I have Outlook 2007 on a two year old computer running Vista. How do I copy my Outlook Contacts list and move them over to Outlook 2010 on a brand new Using Outlook 1
D Opening files in Mail Folders takes 15 seconds - running slow ? Using Outlook 4
D User running outlook 2003 not able to connect to Exchange server 2007 Using Outlook 5
P 2 Member DAG - Members Virtualised running on non Clustered Hosts - supported Configuration? Exchange Server Administration 2
M Business Contact Manager 2010 - Running With Custom Mail Profile Using Outlook 2
B Outlook 2010 CAN'T Connect to 2 Different Exchange Servers running Exchange 2010?!?!?!?!?!?! Using Outlook 1
B Outlook 2010 CAN'T Connect to 2 Different Exchange Servers running Exchange 2010?!?!?!?!?!?! Using Outlook 5
C Help! Running Outlook 2010....merged mail from old laptop to new and now I have three separate sections. Using Outlook 1
G With my PC, running on operating system Vista SP2, I cannot synchronise Microsoft Notes (Outlook 2003 SP3) with my iphone 3GS Using Outlook 3
M I am running outlook 2007 on a hosted exchange server. When I try to send an email and click the To: box there are two contact options - how do I get Using Outlook 1
M Transfer Outlook 2007 PST file to new computer running Outlook 2010 Using Outlook 2
U Outlook 2007 no longer syncing calendar with iPhone 3GS running iOS 4.2.1 via iTunes 10.1.0.54 USB. Using Outlook 6
K Does anyone know how to turn off auto capitalization in Outlook 2007 running on Windows 7? Using Outlook 6
H Business Contact Manager 2010 Running On remote desktop / terminal server Enviornment Using Outlook 1
T Problem with Outlook 2007 (running Vista) There was an error synchronizing your folder hierarchy. Er Using Outlook 1
J Outlook 2007 close but Outlook.exe still running Using Outlook 1
E Re: LDAP search is very slow with Outlook 2007 running on Windows 7 Using Outlook 1
S Outlook 2010 with Exchange 2k3 back end running VERY VERY slow... Using Outlook 1
E LDAP search is very slow with Outlook 2007 running on Windows 7 Using Outlook 1
I Running two or more email profiles concurrently in Outlook 2010 Using Outlook 5
B When office is running in the background it freezes other applications on intervals. Using Outlook 1
N Importing Contacts file to Outlook 2003 running on Windows 7 Using Outlook 5

Similar threads

Top