Results 1 to 4 of 4

Thread: Macro does not work on other Outlook client

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Mar 2023
    Posts
    5
    Location

    Macro does not work on other Outlook client

    Hi,


    I've a working VBA code (see att). What is does: Selecting one or more received mail items in Outlook and the macro put a TAG in front of the subject field on every selected mail item. Then every selected item is forwarded to a specific mail adres.

    Sub ForwardSelectedItems()
    '
    Dim forwardmail As MailItem
    Dim itm As Object
    Dim Xsubject As String
    Dim itmSel As Selection
    Dim n As Long
    Set itmSel = ActiveExplorer.Selection
    n = itmSel.Count
    Do While n > 0
        Set itm = itmSel.Item(n)
        Xsubject = itm.Subject
        If itm.Class = olMail Then
            Set forwardmail = itm.Forward
            forwardmail.Recipients.Add emailto@testdomain.com
            forwardmail.Subject = "[TAG] " & Xsubject
            forwardmail.Display
            forwardmail.Send
        End If
        n = n - 1
    Loop
    End Sub
    The code works fine on one outlook client. Same macro on other pc outlook gives an error "Compile error: Syntaxerror".

    On both outlook clients the object library reference "Microsoft Outlook 16.0 Object Library" is selected.
    Attached Files Attached Files
    Last edited by Aussiebear; 01-17-2024 at 03:50 PM. Reason: Added the code directly to the post

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •