• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 881
  • Last Modified:

Installing outlook code

i need to get this installed so i can be prompted which outlook account to send from before i send.
http://www.daniel-mitchell.com/2007/08/03/outlook-2007-prompt-for-user-account-when-sending-email/

Open in new window


i need the step by step instructions prior to where these starts
0
g11media
Asked:
g11media
  • 14
  • 5
  • 4
  • +2
1 Solution
 
BCipolloneCommented:
Right click ribbon > Customize Ribbon > All Commands > Macros > Add >> 

May need to create a custom group to add this command to...

After it is added click on Macros v > Macros

Input the name and Code then the next time you click on macros it should appear in the drop down list.
0
 
g11mediaAuthor Commented:
what "ribbon" where do i find the ribbon?
0
 
Chris BottomleyCommented:
What version of outlook?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
g11mediaAuthor Commented:
2007
0
 
Chris BottomleyCommented:
In outlook select alt + F11

In the Visual Basic Editor, (VBE) press ctrl + R.  You should see a window "Project" or the likes..  In this window expand:

Project as displayed to reveal MS outlook objects and expand this to display thisOutlookSession.

Paste the code in this module.  Now check security

In the application select Tools | Macro | Security
      : Outlook Application - Warnings for all Macros

Exit outlook and save the project as you do so.

Re-open outlook and does it work?

Chris
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
I  tested it and it worked, but don't forget to create the form as well.

Click (from the code menu) "Insert/User Form" then insert the code in the second part of the instructions into the body of the form you have created.

The two buttons are "Cancel" on left and "Send" on Right. and the wording above the textbox area is "Select an Account for Sent Item:" (hard to see in the diagram)

I have created a complete step by step tutorial if you need it.
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
By the way, the code will only work in 2007 (or later) because it makes use of the Outlook objects "Account" instance variable, which does not exist in versions of Outlook earlier than 2007. There is no work-around to access account information or change accounts on outward email items in 2003, unfortunately.

You will have to read all the added notes after the code given in the link. It highlights changing the names of form objects etc.

I have a tutorial that describes step by step how to achieve your requirement, although I created it in Outlook 2003 (the procedure is probably the same in Outlook 2007). It was disappointing it did not work in 2003, but there you go!
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
I will put the tutorial up this afternoon (in about 6 hours)
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Sorry...still orking on the tutorial...will upload this afternoon.
Stand by....
0
 
David LeeCommented:
Hi, g11media.

There's a much simpler means of doing this that requires far less code and doesn't involve creating a form.  That is to display a dialog-box each time you send that reminds you which account you're sending through and giving you the option to cancel the send and switch accounts.  Here's the code.  Follow these instructions to add it to Outlook.

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 Outlook's VB Editor window
5.  Edit the code as needed.  I included comment lines wherever something needs to or can change
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools > Trust Center
9.  Click Macro Security
10. Set Macro Security to "Warnings for all macros"
11. Click OK
12. Close Outlook
13. Start Outlook.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If msgbox("Are you sure you want to send them message through the " & Item.SendUsingAccount & " account?", vbYesNo + vbApplicationModal, "Verify Sending Account") = vbNo Then
        Cancel = True
    End If
End Sub

Open in new window

0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
That is a nice simple solution BlueDevilFan.

Again it will only work in Outlook 97 or later (which is finr for g11media (th author) I am sure.

Since I have put a lot of work into the tutorial , g11media, do you still want me to upload it?

Cheers
craisin (Chris)
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Oops! That should read "Outlook 2007" not Outlook 97...sorry!
0
 
David LeeCommented:
Hi, craisin.

Thanks.  You're correct.  The code I uploaded will only work for Outlook 2007 and later.  I'd like to see the tutorial you've put together.
0
 
g11mediaAuthor Commented:
PLEASE put tutorial up. Thank you! looking forward to getting this done tonight. i have been traveling, so sorry for delay in responding.
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
OK...shall do...Keep your eyes open for tutorial. I am undergoing lasewr surgery on my left eye today so there will be a couple of days delay....Stay tuned though  :-)
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Is a powerpoint presentation OK (PPS/PPT) ?
0
 
g11mediaAuthor Commented:
sure
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
I will try to do it this avo before I go into surgery
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
OK, here it is.

There may be a few typos, but I have run out of time.

Remember, this was created in Outlook 2003 so the environment may be a little different to Oylook 2007, and the macro will only run in Outlook 2007 or later.

Sorry that the coide is a blue color (haven't got time to recapture the scren with easier to see code).

Basically it is the code already contained in the article you referenced on the website at the top of this question. I added a little bit to enable the user to double-click the account when the selection box pops up rather than having to select then click a button.

Let me know if you find any errors, and when my eye gets better (I hope) I will fix any problems.

Cheers...Chris (craisin)
InstallingOutlookCode.ppt
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Oops! Only the first slide is there...let me try again...

InstallingOutlookCode.ppt
0
 
David LeeCommented:
Nicely done, Chris (craisin)!  I hope the eye surgery went well, or goes well if you haven't had it done yet.  
0
 
g11mediaAuthor Commented:
so bluedevilfan, the solution you provided work well, but i am finding that it is freezing my outlook. I am troubleshooting it, but just thought i would mention that to see if anyone else is having any issue.
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Have you tried my soilution? The code is for Outlook 2007 or later.
0
 
David LeeCommented:
Freezing Outlook in what way?  The code is only invoked when something is sent.  It's impossible for it to affect Outlook at any other time.  I use the same code on my system and I haven't noticed any problems.
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Yes, I cannot see any reason why BlueDevilFan's code should not work UNLESS you are using a version of Outlook earlier than Outlook 97. Then it definately will freeze outlook (oputlook does not display an error for invalud macro execution unless the VBEditor is open).
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
g11media,

I rushed the tutorail for you before my eye operation. Was it of interest?

(By the way, the operation was a complete success....the only thing that hurt was my wallet!)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 14
  • 5
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now