VBA that creates a new Outlook email message and brings the unsent message to the top (1 Viewer)

chuckcoleman

Registered User.
Local time
Today, 18:57
Joined
Aug 20, 2010
Messages
357
Hi, I have code that works well from an Access form that takes the data I want and creates a new Outlook email message. The problem I'm having is when the new email message is created, it stays behind Access. Although Windows has a flashing icon on the task bar, it's easy to overlook. What I'm trying to do is to force the newly created email message to show up on top of the Access form. The code I use that pertains to this discussion is below:

.Attachments.Add strHyperlinkFile
.Display
oApp.ActiveWindow.Activate

End With
Set oEmail = Nothing
Set oApp = Nothing

I know the .Display displays the message vs .Send that just sends it out. How do I get the message to display on top of Access?

Thanks,

Chuck
 

chuckcoleman

Registered User.
Local time
Today, 18:57
Joined
Aug 20, 2010
Messages
357
Hi, I have code that works well from an Access form that takes the data I want and creates a new Outlook email message. The problem I'm having is when the new email message is created, it stays behind Access. Although Windows has a flashing icon on the task bar, it's easy to overlook. What I'm trying to do is to force the newly created email message to show up on top of the Access form. The code I use that pertains to this discussion is below:

.Attachments.Add strHyperlinkFile
.Display
oApp.ActiveWindow.Activate

End With
Set oEmail = Nothing
Set oApp = Nothing

I know the .Display displays the message vs .Send that just sends it out. How do I get the message to display on top of Access?

Thanks,

Chuck
Update: I found a way to make this work. Before I start adding my .Recipients, .Subject, .Body data I added a line, DoCmd.RunCommand acCmdAppMinimize After the end of the email piece, i.e. Set oEmail = Nothing, Set oApp = Nothing, I added, DoCmd.RunCommand acCmdAppRestore. It does what I was looking for. I hope this helps others.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 18:57
Joined
Feb 28, 2001
Messages
27,001
Oddly enough, I never had the problem you describe when using Outlook via Access automation. Perhaps you had some mode flag set wrong in the display. It is the normal i.e. "natural" method of Windows that it would put the most recently activated item on top. Unless you did something to explicitly change priorities, ALL user-created processes are of equal priority so that wouldn't cause the problem you describe.

However, your method certainly would work and there is nothing wrong with your choice. Good luck moving forward with your project.
 

Users who are viewing this thread

Top Bottom