We help IT Professionals succeed at work.
Get Started

How to use more than one "Application_ItemSend" in VBA script for Outlook.

David Bigelow
Last Modified: 2020-01-21
I want both of these scripts to run before I send an email; however, a duplicate command is causing an error message. I really don't know VBA, just enough to copy/paste.

Grammar Check with Spelling
'Occurs before sending email
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim objMail As Outlook.MailItem
    Dim objMailDocument As Word.Document
    Dim objWordApp As Word.Application
    Dim strMsg As String
    Dim nAnswer As Integer
    If TypeOf Item Is MailItem Then
       Set objMail = Item
       Set objMailDocument = objMail.GetInspector.WordEditor
       Set objWordApp = objMailDocument.Application
       'Ask you if to spell check
       strMsg = "Do you want to spell check the email right now?"
       nAnswer = MsgBox(strMsg, vbQuestion + vbYesNo, "Spell Check")
       If nAnswer = vbYes Then
          'Start spell check
          If objWordApp.Options.CheckGrammarWithSpelling = True Then
          End If
       End If
    End If
End Sub

And then this Category script.

'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
    End If
End Sub
Watch Question
Analyst Assistant
Distinguished Expert 2020
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE