Link to home
Start Free TrialLog in
Avatar of A G
A GFlag for United States of America

asked on

How do I bring a msgbox up front on Outlook VBA?

Ok , I have the following code. It just makes a msgbox come up so the user can determine to send the email with encryption or not. The msgbox pops up bu behind the email. So, the user need to minimize the mail and clilck the box over there. Is there a way to popup the msgbo box upfron over everything?

Thanks
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

  Dim intRes As Integer

  Dim strMsg As String

 

  If Item.Attachments.Count > 0 Then

    strMsg = "Your " & Chr(34) & Item.Subject & Chr(34) & " message to " & _

             Item.Recipients.Count & " recipient(s) including " & _

             Item.Recipients.Item(1).Name & _

             " contains at least one attachment. " & vbCrLf & vbCrLf & _

             "Should this message be sent as secure?"

    intRes = MsgBox(strMsg, vbYesNo + vbExclamation, "Confirm File Send")

    If intRes = vbNo Then

      ' cancel send

      Cancel = True

    End If

  End If

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of A G

ASKER

sedgwick:
Thanks, it works. However , is there a way to keep the message just behind the msgbox. Because with your code it takes me to the outlook window and the msgbox is in the front (the message screen is behind msgbox and outlook and it cannot be seen).
So is there a way to view the msgbox infront of the mail screen rather than the outlook screen.
thanks
I am getting some code up that will solve this problem...stand by
Using API calls you can get the window number of the Outlook window and then minimize it just before the call to the MsgBox function.
 
 
 
 
Avatar of A G

ASKER

Craisin, when you say API calls?
How do you use them?
Can you give an example?
Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial