×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Microsoft Outlook Code?

Microsoft Outlook Code?

Microsoft Outlook Code?

(OP)
I just learned it is possible to use VBA code in Outlook. Looking at it, I see how to insert a module, but I am not sure if that is how I would go about it or not. I suck with VBA and am not much better with Outlook.

Everyone uses Outlook at my work. Right now when we get an email, I get a small message box that pops up dont next to the clock. Unfortunately when I am focused on minute things on the screen, I will never see that pop-up way down int he corner and sometimes when I get an email asking me to come help someone, I wont see the email four a couple hours.

What I want to do....

1) Create code that will attach to my Outlook so that every day when I open outlook it will automatically open as well. In excel the modules we place code in seem to be attached to files and not excel itself. For outlook I want to make sure it opens with the program.

2) When I get new email, I want a message to pop up in the middle of my monitor telling me to check my mail and I want it to stay there until I click OK. That way if I am away from my computer it will still be there when I get back.

Is this possible with Outlook?



RE: Microsoft Outlook Code?

Wow, that sounds super annoying. The pop up in the task bar was annoying enough; I turned that off. My attitude toward email is: "If you email me, I'll get to it when I get to it. If it is urgent, call me or come talk to me." If something takes over my screen every 10 minutes, I'll never get anything done.

Be careful what you wish for...

[edited for clarity]

RE: Microsoft Outlook Code?

(OP)
Thanks cowski

I dont get a lot of emails at work. The ones I do get, 99% of them are from people I work with. Either Leaders sending me a job request or someone needing help on one program or another.

To be honest though, I am unsure how to email you. I see the button for Email Thread but not sure if that goes to you or what. I clicked on your name and I dont see anything there on how to email you. Sorry for my ignorance in this area.

RE: Microsoft Outlook Code?

Ken,

Every Microsoft application has VBA capabilities “built in.” Excel, Word, Outlook, PowerPoint, Access all can be automated. BTW, in each application, including Excel, the code modules are saved WITH the Workbook, Document, Presentation.

Outlook is an outlier in many respects. I’d suggest posting your question in Tek-Tips VBA Visual Basic for Applications (Microsoft)
http://www.tek-tips.com/threadminder.cfm?pid=707

I am not conversant with the Outlook Object Model, although I’ve done some coding in Outlook VBA. There may be some here at Eng-Tips and there are a few at Tek-Tips.

Whatever you decide to do, you’ll need to do a lot of “heavy lifting” on your own. You’ll be building your VBA toolbox and “I just learned...” will become a more regular utterance.

Here’s a valuable tool that I use regularly...
How to use the Watch Window as a Power Programming Tool http://www.tek-tips.com/faqs.cfm?fid=4594

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Microsoft Outlook Code?

(OP)
And definitely no hurry at all. I have lived without it in this company since 2010, I can go a while longer. lol

RE: Microsoft Outlook Code?

(OP)
Thanks Skip

I will probably do that. I just looked at the Powerful programming Tool you gave a link to. Kind of scary reading that post. Afraid it may be stepping into something way above my head. lol Though I seem to make it a habit of getting myself into these messes anyway, so I will be stepping in. lol

Im already saying "I just learned...” quite often when it comes to the basic stuff of VBA. lol

RE: Microsoft Outlook Code?

At 76, I still utter those words and will past my dying day.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Microsoft Outlook Code?

(OP)
May it never end for either of us.

RE: Microsoft Outlook Code?

You'd be better off ignoring any VBA and just setting Outlook to run on startup, at least for the first part of your question.

Its likely possible to use VBA to generate a message window whenever a new email is received, but I'd agree wholeheartedly with cowski, it'll be so annoying and counterproductive that you'd turn it off again. You're better off changing your workflow or habits than attempt to get Outlook to alert you to new emails. There's probably a setting somewhere to make the new email notification persistent, which would remove all need for VBA.

There's plenty that VBA can do for you, I'd suggest that this case isn't one of them.

EDMS Australia

RE: Microsoft Outlook Code?

(OP)
If you get 50+ emails a day, I can see where this would be ridiculous. When you get 3 to 10 emails a day and most of them are emails you want to act upon asap, this would be helpful.

I have messed with the pop-up in the past. However I change it, it still stays a small mesage down in the corner that I dont see pop-up.

At this moment, I have three windows explorer folders, Outlook, the internet, two files of excel, WESS (GM Program), and NX open and spread out across two monitors. When I am at my desk, I am focusing on other areas of the monitor and dont see the pop-up. (My eyes getting worse and worse dont help) and I might be focusing on the job I am doing for hours at a time. I try to remember to check my email, but too often I am too focused on other things and it doesnt even come to mind.

Believe me, I have given it thought and I know this isnt something most people would want. Not everyones situation is like yours though. I would rather it force my attention to the fact I have an email once every couple hours, rather than leave a boss waiting for an hour and a half to get something done that should have taken me ten minutes.

RE: Microsoft Outlook Code?

What version of Outlook?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Microsoft Outlook Code?

(OP)
Microsoft Office Professional Plus 2010

Version: 14.0.7116.5000 (32-bit)

RE: Microsoft Outlook Code?

Set a more noticeable audio alert.

RE: Microsoft Outlook Code?

(OP)
Unfortunately we dont have sound hooked up to our computers. People can listen to headphones but they hook them up to their phones and Ipods.

RE: Microsoft Outlook Code?

Here's a link that tells you how to create a shortcut that will run your macro whenever Outlook starts:
https://superuser.com/questions/844739/how-to-auto...

Your shortcut will be something like:
"C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE" /autorun mainMailWatcher
Don't change the "mainMailWatcher" part.

Here's some info on how Outlook stores and saves code (basically it sucks):
http://www.outlookcode.com/article.aspx?id=28
Follow the instructions for importing.

You will have to enable macros for this to work. Your default macro security settings probably block all macros without even telling you. The macro will let you know if it starts with a message box that says "Watching for mail..."

Here are the code Module, Class Module, and UserForm you need to import. It doesn't lock up your whole PC until you dismiss the message, but it is big and stays on top.

RE: Microsoft Outlook Code?

(OP)
Sorry Handleman, I never saw your reply until today.

Between Handleman's and MintJulep's replies, I was able to get this working. Unfortunately there is one thing happening that actually makes it worse for me if I cant fix it. lol It pops up a message box right in the middle of the screen. That is great. Unfortunately, it doesnt make that message box the focused window. So if I am working on excel and staring at a zillion numbers and I get an email, that message box pops up but stays in the background behind my excel or whatever program I am working on. And so I never see it. To make it worse, the tiny notification Outlook usually pops up in the corner of the screen wont pop up until after I click OK on that message box, which hides behind the program I am on. lol So now I dont even get that tiny notification to let me know. lol

Still, this is a big leap forward with only a small problem to figure out.

In my searching I am finding some pieces of code that might work but so far none do, though that is very likely because I have no idea how to place it in this code that MintJulep provided in his/her link. . lol

RE: Microsoft Outlook Code?

Sooo.... Part of my stuff was a giant message box (actually a UserForm) that does make itself always on top. What I posted is a complete solution. If you try to take bits and pieces of it and put it into other partial solutions without knowing what you're doing you will end up.... well, exactly where you are.

Sorry... Not trying to be an ass. But I put some effort into actually writing the thing that did what you asked for instead of exactly what the code in the link does.

RE: Microsoft Outlook Code?

(OP)
Sorry... I have switched over and trying yours. I imported all four files and I copied the module with ....
Private Sub Application_NewMailEx ..... over to ThisOutlookSession. It wants to work but it gives me...

Error: 5 Invalid procedure call or argument.

I have copied all of them to the ThisOutlookSession and tried moving them around. The best I got so far was for that error to come up and when I hit OK, the big message popped up. I havent gotten back to that happening since. lol

Did I say I suck with code?
As of right now, this is what that code looks like.... (Dont laugh if I messed it up.... nah, go ahead and laugh. You might as well enjoy helping me.) I will look to see if there is a reply in the morning.





Dim mymailwatcher As clsMailWatcher

Dim WithEvents myOutlook As Outlook.Application

Sub mainMailWatcher()
MsgBox "Watching for mail..."
Set mymailwatcher = New clsMailWatcher
End Sub


Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim strIDs: strIDs = Split(EntryIDCollection, ",")
Dim oMail As MailItem, nIndex
Dim oNameSpace As NameSpace
Set oNameSpace = Application.GetNamespace("MAPI")

On Error GoTo koniec
For nIndex = 0 To UBound(strIDs)
Set oMail = oNameSpace.GetItemFromID(strIDs(nIndex))
MsgBox "Message is knocking to you: " & _
oMail.SenderName & vbCr _
& oMail.FormDescription & vbCr _
& oMail.ReplyRecipients & vbCr _
& oMail.Recipients(1).Address, vbInformation, "Your Outlook Alert"
Next
Exit Sub
koniec:
MsgBox "Error: " & Err.Number & " " & Err.Description, vbExclamation, "VBATools.pl"

End Sub


Private Sub Class_Initialize()
Set myOutlook = Outlook.Application
End Sub

Private Sub myOutlook_NewMail()
'MsgBox "You've got mail!"
frmMailMessage.Show
End Sub


P.S.
I love the message. lol

RE: Microsoft Outlook Code?

OK... Get rid of everything in the link that MJ posted. It is extraneous. The stuff I wrote doesn't need to go in ThisOutlookSession or whatever. All you have to do is import the 3 things. Just leave them exactly as imported. Then make your Outlook shortcut as per the instructions.

RE: Microsoft Outlook Code?

(OP)
Thanks Handleman

I didnt realize I was doing just as you said. Because I started with the other I didnt realize I started putting them together without realizing it. I had everything jacked up. Finally I just deleted all the modules and everything out of Outlook and even the files I downloaded from you and started over. Then once I actually read the shortcut message from you clearer I went into the shortcut I made and added the last bit to the target and bam, it worked. lol

Amazing how critical it can be to actually "read" instructions huh?

I do appreciate the work you put into this and it will do exactly as I was hoping for. And I am even keeping the little sarcastic "Okay Already!" lol

Thankyou very much. I have a feeling there will be a few people here who will want this. :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

White Paper – Choosing the Right Spring Loaded Connector
In today’s cost-sensitive world, designers are often driven to specify the lowest cost solution for every aspect of their designs to ensure that their solution is competitively priced and their company remains profitable. However, specifying a low-cost, low-quality connector solution can result in premature failure, considerable re-work costs and damage to reputations. Download Now
eBook – Own the Lifecycle: Sustainable Business Transformation
Increasingly, product and services companies are seeking more information and control in the operational lifecycle of their products, including service and use. Better information about the operational lifecycle, and the ability to use that information, requires more than just unstructured data flowing back from products in the field. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close