Consulting

Results 1 to 3 of 3

Thread: MailItem.Reply | ReplyAll | Forward

  1. #1
    VBAX Regular
    Joined
    Jul 2010
    Posts
    29
    Location

    MailItem.Reply | ReplyAll | Forward

    Hello,

    Is there anyway I can pass the option as a parameter. I'm currently doing this - the RespondType parameter is passed from another (public) Sub, the one which people will press from the ribbon.

    Sub RespondWithDefaultAccount(ByVal RespondType As String)
    
    On Error GoTo ErrorHandler
    
    
    Dim Result As String
    Dim Account As Outlook.Account
    
    
    Select Case TypeName(Outlook.ActiveWindow)
    
    
        Case "Explorer"
        
            Select Case RespondType
            
                Case "Reply"
                
                    Set Item = Outlook.ActiveExplorer.Selection.Item(1).Reply
                    
                Case "ReplyAll"
                
                    Set Item = Outlook.ActiveExplorer.Selection.Item(1).ReplyAll
                    
                Case "Forward"
                
                    Set Item = Outlook.ActiveExplorer.Selection.Item(1).Forward
                    
            End Select
            
        Case "Inspector"
        
            Select Case RespondType
            
                Case "Reply"
                
                    Set Item = Outlook.ActiveInspector.CurrentItem.Reply
                    
                Case "ReplyAll"
                
                    Set Item = Outlook.ActiveInspector.CurrentItem.ReplyAll
                    
                Case "Forward"
                
                    Set Item = Outlook.ActiveInspector.CurrentItem.Forward
                    
            End Select
            
    End Select
    
    ...
    
    End Sub
    So the RespondType case statement is repeated. Can I somehow do this:

    Sub RespondWithDefaultAccount(ByVal RespondType As String)
    
    On Error GoTo ErrorHandler
    
    
    Dim Result As String
    Dim Account As Outlook.Account
    
    
    Select Case TypeName(Outlook.ActiveWindow)
    
    
        Case "Explorer"
        
            Set Item = Outlook.ActiveExplorer.Selection.Item(1).RespondType
            
        Case "Inspector"
        
            Set Item = Outlook.ActiveInspector.CurrentItem.RespondType
            
    End Select
    Thanks!

  2. #2
    VBAX Regular
    Joined
    Jul 2010
    Posts
    29
    Location
    PS: What I am trying to do is have Outlook always use the default account for new emails, replies, reply all and forwards when doing any of those from an additional account setup in Outlook. Is there a better way to hijack the default actions rather than having custom buttons?

  3. #3
    VBAX Regular
    Joined
    Jul 2010
    Posts
    29
    Location
    There is a better way. You can hijack the default actions.

    Does any one know if there's a way to hijack Forward as Attachment though? For a normal forward I'm doing this:

    Private Sub Item_Forward(ByVal Response As Object, Cancel As Boolean)
    
        Response.SendUsingAccount = DefaultAccount()
        
    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
  •