PDA

View Full Version : [SOLVED:] MailItem.Reply | ReplyAll | Forward



ldoodle
01-24-2019, 03:16 AM
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!

ldoodle
01-24-2019, 04:32 AM
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?

ldoodle
01-24-2019, 08:00 AM
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