Link to home
Start Free TrialLog in
Avatar of xemophora
xemophoraFlag for United States of America

asked on

Need a prompt to select the send from account on new messages

Here is the problem, we use multiple email address (Exchange email account, pop3 accounts, http accounts) and different clients recieve messages from different accounts.  There have been mix ups when someone has forgotten to change the send from address manually and the client did not recieve the email or deleted it because of it being an unknown address to them.  What we need is a script or utility or something to give a prompt when hitting the send button on new messages asking which account we would like to send from.  Replies are not of a big concern due to the way outlook handles them so this only needs to happen on new messages.  Any thoughts?  

I have tried http://www.addins4outlook.com/sendaccount/default.asp with no success.  The program sounds like everything we need but it only works on a per email address basis (meaning it only works on email address you add to the database, for the rules to apply you have to manually add the recieving address to the database since the automatic features were not working).  Tech support offered no help to me as to why the automatic features (when active) would not let me send any emails period.  

Does anyone know of a way to accomplish this or even an existing utility that does this?  
Avatar of David Lee
David Lee
Flag of United States of America image

Hi, xemophora.

I can solve this with a bit of scripting.  That script would have to be installed on all computers though and installation is a manual process.  If that's not a problem, then I can post the code and instructions for using it.
Avatar of xemophora

ASKER

That would be perfectly fine we only have 10 pcs so manual installation isn't a big deal. Thank you for taking the time to do this as well I have tried with no success learning to code
Ok.  I'm travelling for the next couple of days, so please be patient.  I'll get to this as soon as I can.
No worries, it would take me much longer than a few days so its not a big deal.
This should do it.  I say "should" because I don't have a 2003 computer with multiple accounts to test the code on.  Follow these instructions to use this.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of
5.  Outlook's VB Editor window
6.  Edit the code as needed.  I included comment lines wherever something needs to or can change
7.  Click the diskette icon on the toolbar to save the changes
8.  Close the VB Editor
9.  Click Tools->Macro->Security
10. Set the Security Level to Medium
11. Close Outlook
12. Start Outlook
13. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

Each time you send a message you'll be presented with a dialog-box asking which account you want to use.  You'll need to type in the number corresponding to the correct account.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim olkInspector As Object, _
        ofcBar As Object, _
        ofcButton As Object, _
        intAccount As Integer
    intAccount = InputBox("Enter the number of the account to send this message through", "Select Account")
    Set olkInspector = Application.ActiveInspector
    Set ofcBar = olkInspector.CommandBars("Standard")
    Set ofcButton = ofcBar.Controls(3)
    ofcButton.Controls(intAccount).Execute
    olkInspector.Close olSave
    Set ofcButton = Nothing
    Set ofcBar = Nothing
    Set olkInspector = Nothing
End Sub

Open in new window

Thanks,  however, this did not work.  The window appeared in the application but no on top of the message so you had to change windows in order to see the result after hitting send.  Also no matter if i type 1, 2, or 3 it still sends from my primary account.  Is there anyway of doing something similar to this?
(see attached)
I have made the window and would like the accounts to be read back into that field, you simply click the one you want and hit "send from."  Or even if you could point me in the direction as to how i would do this?  
sendaccounts.jpg
"The window appeared in the application but no on top of the message so you had to change windows in order to see the result after hitting send."
Unfortunately, I can't control how the input window appears.  I've since tested the code and it worked fine on my system, including the input window appearing on top of, not under, the other windows.  I thought about a userform for this, but if the basic code doesn't work on your system, then changing the input form won't make any difference.  When you create a message do you have a pulldown next to the Send button labeled Accounts?  Does it show all three of your accounts?
The accounts drop down does show all of them yes.  I am not sure why the window is not coming up right or the numbers are not applying.  Thanks for your help though.  Do you have any ideas as to why it may not work?
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i am out of the office until monday so it will be a few days before i am able to do this.... in the mean time... thanks for endouring all of this here are your points in advance.
thank you and i wil let you know as soon as i get in to go through the code.
Thanks.  I'll be here whenever you want to pick this up again.
Avatar of finster
finster

OK, so this topic is a year old, but I have managed to extend it somewhat....
The number you select starts at 1, which represents your default account, and then increments through the other accounts *including* a repeat of your default account, so you have to discount the default account to get the correct index.
I created a form within the Outlook VBA session (images attached below)
I also show my list of accounts with id 1 being the default account, and ids 2 to 7 being all available accounts
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim olkInspector As Object, _
        ofcBar As Object, _
        ofcButton As Object, _
        intAccount As Integer
        
    UserForm1.Show vbModal
    intAccount = UserForm1.Label1.Caption
 
    Unload UserForm1
 
    If intAccount <= 0 Then
        Cancel = True
    Else    
        Set olkInspector = Application.ActiveInspector
        Set ofcBar = olkInspector.CommandBars("Standard")
        Set ofcButton = ofcBar.Controls(3)
                
        ofcButton.Controls(intAccount).Execute
        olkInspector.Close olSave
    
    End If
        
    Set ofcButton = Nothing
    Set ofcBar = Nothing
    Set olkInspector = Nothing
 
End Sub
 
'and the 2 buttons on the UserForm1
 
Private Sub cmdCancel_Click()
    Label1.Caption = -1
    Me.Hide
End Sub
 
Private Sub cmdOK_Click()
 
    If OptionButton1.Value = True Then Label1.Caption = OptionButton1.Tag
    If OptionButton2.Value = True Then Label1.Caption = OptionButton2.Tag
    If OptionButton3.Value = True Then Label1.Caption = OptionButton3.Tag
    If OptionButton4.Value = True Then Label1.Caption = OptionButton4.Tag
    If OptionButton5.Value = True Then Label1.Caption = OptionButton5.Tag
    If OptionButton6.Value = True Then Label1.Caption = OptionButton6.Tag
 
    Me.Hide
End Sub

Open in new window

UserForm1.png
Accounts.png