Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Posts
    410
    Thanks
    1
    Thanked 0 Times in 0 Posts

    outlook forward message macro (2003)

    I would like to have a macro that takes the current email, forwards it (alt-w), and selects the proper list of contacts (currently Personal Folders/Contacts/Personal Contacts).

    I went to build my first outlook macro and found out it doesn't record keystrokes as does Word and Excel. (and what's up with that?)

    Suggestions?
    thanks.

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: outlook forward message macro (2003)

    Have you looked at using a Rule for forwarding? You should be able to create one.

    Yes, Outlook doesn't have a macro recorder and is a strange object model compared to Excel and Word. If you want to teach yourself, most beginning Outlook macro writers start with Sue Mosher's book Microsoft Outlook Programming; Jumpstart ... and website http://www.outlookcode.com. There are also many Outlook Object Model comments and Outlook VBA code threads in this Forum.

    To work on an existing open message, you probably want to start with the ActiveInspector.CurrentItem object, and you will find the Properties and Methods applicable to a Message Item if you define the object as a "MailItem"; "Forward" is a specific Property of a MailItem, and .Recipients.Add "names" will specifiy recipients.

    Post back if you need additional help.
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: outlook forward message macro (2003)

    That Rory, always complaining about the Outlook Object Model. <img src=/S/rofl.gif border=0 alt=rofl width=15 height=15>

    I'm guessing the OP John will need help getting mail addresses out of his contacts sub-folder. I don't think I have coded a feed from a Contacts Folder to a MailItem.Recipients list, should be simple to write a loop.
    -John ... I float in liquid gardens
    UTC -7ąDS

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: outlook forward message macro (2003)

    As John (I erroneously wrote Rory originally) already noted, the Outlook object model is weird, and it is limited. You can create and process e-mails, appointments etc., but you have much less control than in Word or Excel. I wouldn't know how to select a specific address list in code in such a way that the user sees it, for example.

    Here is a sample macro that is more or less the equivalent of pressing the Forward button:

    Sub ForwardIt()
    Dim olItem As MailItem
    Select Case TypeName(ActiveWindow)
    Case "Inspector"
    If Not ActiveInspector.CurrentItem.Class = olMail Then
    MsgBox "This item is not an e-mail message.", vbExclamation
    Exit Sub
    End If
    Set olItem = ActiveInspector.CurrentItem
    Case "Explorer"
    If Not ActiveExplorer.Selection.Count = 1 Then
    MsgBox "You have selected no item or multiple items.", vbExclamation
    Exit Sub
    End If
    If Not ActiveExplorer.Selection.Item(1).Class = olMail Then
    MsgBox "This item is not an e-mail message.", vbExclamation
    Exit Sub
    End If
    Set olItem = ActiveExplorer.Selection.Item(1)
    End Select
    Set olItem = olItem.Forward
    olItem.Display
    End Sub

Posting Permissions

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