Solved

Installing outlook code

Posted on 2011-02-11
26
869 Views
Last Modified: 2012-05-11
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
Comment
Question by:g11media
  • 14
  • 5
  • 4
  • +2
26 Comments
 
LVL 13

Expert Comment

by:BCipollone
ID: 34876481
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
 

Author Comment

by:g11media
ID: 34876559
what "ribbon" where do i find the ribbon?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34876724
What version of outlook?
0
 

Author Comment

by:g11media
ID: 34876745
2007
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34876780
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
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34878538
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
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34879135
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
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34892260
I will put the tutorial up this afternoon (in about 6 hours)
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34893655
Sorry...still orking on the tutorial...will upload this afternoon.
Stand by....
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 34895513
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
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34895565
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
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34895610
Oops! That should read "Outlook 2007" not Outlook 97...sorry!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34901375
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:g11media
ID: 34913108
PLEASE put tutorial up. Thank you! looking forward to getting this done tonight. i have been traveling, so sorry for delay in responding.
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34913148
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
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34913161
Is a powerpoint presentation OK (PPS/PPT) ?
0
 

Author Comment

by:g11media
ID: 34913246
sure
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34913312
I will try to do it this avo before I go into surgery
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34913851
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
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34913864
Oops! Only the first slide is there...let me try again...

InstallingOutlookCode.ppt
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34914624
Nicely done, Chris (craisin)!  I hope the eye surgery went well, or goes well if you haven't had it done yet.  
0
 

Author Comment

by:g11media
ID: 34917215
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
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34917240
Have you tried my soilution? The code is for Outlook 2007 or later.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34921187
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
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34922974
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
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 34922979
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

My experience with Windows 10 over a one year period and suggestions for smooth operation
Get an idea of what you should include in an email disclaimer with these Top 5 email disclaimer tips.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now