troubleshooting Question

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

Avatar of David Bigelow
David BigelowFlag for United States of America asked on
OutlookVBA
4 Comments1 Solution181 ViewsLast Modified:
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
             objMailDocument.CheckGrammar
          Else
             objMailDocument.CheckSpelling
          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
        Item.ShowCategoriesDialog
   
    End If
   
     
End Sub
ASKER CERTIFIED SOLUTION
NorieAnalyst Assistant
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros