J
Josh
Like many other posters I've seen, I sometimes send mail from the
wrong account in Outlook 2007. I wanted to create a macro that when I
sent a message, would prompt me to verify the sending account, and let
me change if necessary.
I have the following code:
Private Sub Application_ItemSend(ByVal item As Object, Cancel As
Boolean)
If TypeOf item Is Outlook.MailItem Then
'Show form that displays account list and sets
item.SendUsingAccount
'To debug, verify it's using the right account:
msgbox item.SendUsingAccount
End if
End Sub
The routine works in the sense that it displays the list of accounts,
and sets the item.SendUsingAccount value properly (the messagebox
displays the correct value). However, it goes through and sends the
mail from the originally selected account anyways. It seems like once
you get to the ItemSend event, it's too late to change the account for
the current message if it gets sent. However, if something interrupts
the sending process (like another check for having a subject that
could set cancel = TRUE and cancel the sending, or stepping through
the code in debug mode), it will actually update the sending account
(which I can see reflected in the message window, cause it didn't
actually send).
My question is... is there any way to update the SendUsingAccount
property once you get to the ItemSend event? If not, is there an
earlier place to trap this event? Is there a way to trap the event of
clicking the send button and then running this code?
Thanks in advance.
wrong account in Outlook 2007. I wanted to create a macro that when I
sent a message, would prompt me to verify the sending account, and let
me change if necessary.
I have the following code:
Private Sub Application_ItemSend(ByVal item As Object, Cancel As
Boolean)
If TypeOf item Is Outlook.MailItem Then
'Show form that displays account list and sets
item.SendUsingAccount
'To debug, verify it's using the right account:
msgbox item.SendUsingAccount
End if
End Sub
The routine works in the sense that it displays the list of accounts,
and sets the item.SendUsingAccount value properly (the messagebox
displays the correct value). However, it goes through and sends the
mail from the originally selected account anyways. It seems like once
you get to the ItemSend event, it's too late to change the account for
the current message if it gets sent. However, if something interrupts
the sending process (like another check for having a subject that
could set cancel = TRUE and cancel the sending, or stepping through
the code in debug mode), it will actually update the sending account
(which I can see reflected in the message window, cause it didn't
actually send).
My question is... is there any way to update the SendUsingAccount
property once you get to the ItemSend event? If not, is there an
earlier place to trap this event? Is there a way to trap the event of
clicking the send button and then running this code?
Thanks in advance.