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
L Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3
A VBscript stops running after updating form Outlook VBA and Custom Forms 1
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 Using Outlook 0
Diane Poremsky Running Outlook Macros on a Schedule Using Outlook 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
A running code after the new inspector is visible Outlook VBA and Custom Forms 1
M Running Outlook as Scheduled task Outlook VBA and Custom Forms 1
S ActiveExplorer return NULL on new Window user login and running Outlook first time Outlook VBA and Custom Forms 19
E Word macro running from OL VBA throwing error on Word SaveAs?? Outlook VBA and Custom Forms 8
A Running Code in Side by side calendar view Outlook VBA and Custom Forms 2
G Re:Running a Macro when email arrives Outlook VBA and Custom Forms 1
D Running a Program from Custom Action Rule Outlook VBA and Custom Forms 1
O Scheduled Task Fails running Code to send Outlook Mail from Excel. Outlook VBA and Custom Forms 9
B Phantom VBA Running Outlook VBA and Custom Forms 1
G To Prevent Malicious Code from running, one or more objects in thi BCM (Business Contact Manager) 2
M If loop not running Outlook VBA and Custom Forms 1
D Troubleshooting rule/script not running Outlook VBA and Custom Forms 5
P How to use a form from a rule running on the inbox Outlook VBA and Custom Forms 1
S To help prevent malicious code from running, one or more objects in this form were not loaded. For m Outlook VBA and Custom Forms 1
Q Running the Database from a Server BCM (Business Contact Manager) 7
N Running Code before Access 2007 closes down Outlook VBA and Custom Forms 1
S Outlook rules not running automatically Using Outlook 11
K Multiple copies of task being created Using Outlook 2
S Auto forward for multiple emails Outlook VBA and Custom Forms 0
K Multiple Rules on Single Email Using Outlook 2
Cathy Rhone gmail listed multiple times Using Outlook 3

Similar threads

Top