![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |