I need to open outlook mail through my application. I made
an activex control in VB which has the following code:
Public Sub CreateMailObject()
On Error Resume Next
Set outlookApp = CreateObject
("Outlook.Application")
Set objMailItem = outlookApp.CreateItem(0)
End Sub
Public Sub setSubject(subj As String)
On Error Resume Next
objMailItem.Subject = subj 'subject
End Sub
Public Sub setMessage(msg As String)
On Error Resume Next
objMailItem.Body = msg
End Sub
Public Sub setRecipient(recv As String)
On Error Resume Next
objMailItem.Recipients.Add recv
End Sub
Public Sub setDisplay()
On Error Resume Next
objMailItem.display
End Sub
The client side VBScript code invokes these functions
provided by the activex object. Most of the times the
outlook mail window opens in the foreground.
However if i am in Outlook, open an email, close the email
and then select the Send icon on my application, the new
mail item opens in the background.
Could someone let me know why this is happening and how i
could enforce the mail item to open in the foreground
always.
Thanks for the help.
Regards,
Padma
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Padma Priya Gopalan" <pp...@yahoo.com> wrote in message
news:f19c01c11f30$e910ad00$9ae62ecf@tkmsftngxa02...
Thanks a lot for the help.
padma
>.
>
Public Sub CreateMailObject()
On Error Resume Next
Set outlookApp = CreateObject
("Outlook.Application")
Set objMailItem = outlookApp.CreateItem(0)
objMailItem.display '<<<--------------------------<<<
End Sub
Hollis D. Paul [MVP - Outlook]
Hol...@outlookbythesound.com
h...@compuserve.com
Using Virtual Access 4.52 build 277 (32-bit), Windows 2000 build 2195
http://search.support.microsoft.com/kb/c.asp?FR=0&SD=TECH&LN=EN-US
Mukilteo, WA USA
function ForceForegroundWindow(hWnd: THandle): BOOL;
var
hCurWnd: THandle;
begin
hCurWnd := GetForegroundWindow;
AttachThreadInput(
GetWindowThreadProcessId(hCurWnd, nil),
GetCurrentThreadId, True);
Result := SetForegroundWindow(hWnd);
AttachThreadInput(
GetWindowThreadProcessId(hCurWnd, nil),
GetCurrentThreadId, False);
end;
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Hollis D. Paul" <Hol...@outlookbythesound.com> wrote in message
There is no alternative: you need to get down to the Windows API level to set a
foreground window.