A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Creating an Outlook Mail message from Access



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 5th 08, 09:21 PM posted to microsoft.public.outlook.program_vba
ChrisK
external usenet poster
 
Posts: 3
Default Creating an Outlook Mail message from Access

Hi all,

I'm using the following code snippet to create email in Outlook from Access:

Dim appOutlook As Outlook.Application, msg As Outlook.MailItem
On Error GoTo ErrHandler:
Set appOutlook = GetObject(, "Outlook.Application")
Set msg = appOutlook.CreateItem(olMailItem)
With msg
.To = strTo
If strSubject "" Then .Subject = strSubject
If strBody "" Then .Body = strBody
.Display
End With

Is there a method to bring the Outlook mail item window to the front when
this sub is run? At the moment, when the sub is run, the message is created
but doesn't come to the front

CK


Ads
  #2  
Old September 6th 08, 09:17 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Creating an Outlook Mail message from Access

You can't do that from VBA: if you were using C++ or Delphi, you could query
the Inspector object for the IOleWindow interface, call
IOleWindow::GetWindow, then use the Windows API to bring that window to the
front.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ChrisK" wrote in message
...
Hi all,

I'm using the following code snippet to create email in Outlook from
Access:

Dim appOutlook As Outlook.Application, msg As Outlook.MailItem
On Error GoTo ErrHandler:
Set appOutlook = GetObject(, "Outlook.Application")
Set msg = appOutlook.CreateItem(olMailItem)
With msg
.To = strTo
If strSubject "" Then .Subject = strSubject
If strBody "" Then .Body = strBody
.Display
End With

Is there a method to bring the Outlook mail item window to the front when
this sub is run? At the moment, when the sub is run, the message is
created but doesn't come to the front

CK




  #3  
Old September 6th 08, 09:22 AM posted to microsoft.public.outlook.program_vba
ChrisK
external usenet poster
 
Posts: 3
Default Creating an Outlook Mail message from Access

OK, thanks Dmitry...


"Dmitry Streblechenko" wrote in message
...
You can't do that from VBA: if you were using C++ or Delphi, you could
query the Inspector object for the IOleWindow interface, call
IOleWindow::GetWindow, then use the Windows API to bring that window to
the front.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"ChrisK" wrote in message
...
Hi all,

I'm using the following code snippet to create email in Outlook from
Access:

Dim appOutlook As Outlook.Application, msg As Outlook.MailItem
On Error GoTo ErrHandler:
Set appOutlook = GetObject(, "Outlook.Application")
Set msg = appOutlook.CreateItem(olMailItem)
With msg
.To = strTo
If strSubject "" Then .Subject = strSubject
If strBody "" Then .Body = strBody
.Display
End With

Is there a method to bring the Outlook mail item window to the front when
this sub is run? At the moment, when the sub is run, the message is
created but doesn't come to the front

CK






  #4  
Old September 10th 08, 08:08 PM posted to microsoft.public.outlook.program_vba
ted
external usenet poster
 
Posts: 18
Default Creating an Outlook Mail message from Access

ChrisK:
As an Access developer I have applications that send a lot of emails via
Outlook and I don't worry about seeing them, however if I wanted to see or
edit them, I would put a simple VBA statement in my Access code like this:

DoCmd.SendObject acSendNoObject, , , strTo, , , strSubj, strMsg, True

(The True has it open the email for editing before you send it)

You would still use the If rules to check for your zero length values, but
then use the SendObject instead of the Outlook commands so that you can edit
the email. It should use your default Email program which should be Outlook
if it is installed.

You could use this method at all times unless you wanted to do more such as
add attachments like I do, then you would need to use the Outlook commands.

I hope that help.

"ChrisK" wrote:

Hi all,

I'm using the following code snippet to create email in Outlook from Access:

Dim appOutlook As Outlook.Application, msg As Outlook.MailItem
On Error GoTo ErrHandler:
Set appOutlook = GetObject(, "Outlook.Application")
Set msg = appOutlook.CreateItem(olMailItem)
With msg
.To = strTo
If strSubject "" Then .Subject = strSubject
If strBody "" Then .Body = strBody
.Display
End With

Is there a method to bring the Outlook mail item window to the front when
this sub is run? At the moment, when the sub is run, the message is created
but doesn't come to the front

CK



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Message rules in Access FBxiii Outlook and VBA 1 April 11th 08 02:16 PM
Creating New Contacts in Access that Link to Outlook kjschiller Outlook - Using Contacts 0 December 31st 07 01:51 AM
Creating a task in Outlook from Access Blogd_Node Outlook and VBA 4 February 3rd 07 05:38 AM
Contacts viewed thru Contact Icon, no access thru To: when creating an e-mail Beth Outlook - Using Contacts 2 August 31st 06 07:58 PM
Creating New Mail Message to Shared Contact Tom Outlook - Using Contacts 1 April 3rd 06 03:15 PM


All times are GMT +1. The time now is 08:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.