new email form in front of MsgBox

S

Song Su

This code will bring outlook new email and asks user if mail sent or not.
However, new email form is minimized (flashing) and MsgBox shows at front.
How to show new email form in front of MsgBox?

Or, is there a way to detect if user clicked 'send' button of outlook new
email so I don't have to present MsgBox? If not possible, use MsgBox is
fine.

Thanks. Here is the code

Private Sub cmdHelpDesk_Click()
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Dim ctlBody As String
Dim LResponse As Integer

Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
With objMail
.Subject = "PO: " & Me.PONumber & " - " & Me.OfficeID.Column(1)
.To = "(e-mail address removed)"
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>" & ctlBody & "</p></BODY></HTML>"
.Display
End With

Set objMail = Nothing
Set olApp = Nothing

LResponse = MsgBox("Have you sent to ItHelpDesk?", vbYesNo, "Continue")
If LResponse = vbYes Then
Me.HD.SetFocus
Me.cmdHelpDesk.Enabled = False
Me.HD = True
Me.HDDate = Now()
Me.Dirty = False
End If
End Sub
 
B

Beetle

You could try using the .Send method of the Mail object, then you wouldn't
need to ask the users if they sent it or not.

With objMail
.Subject = "PO: " & Me.PONumber & " - " & Me.OfficeID.Column(1)
.To = "(e-mail address removed)"
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>" & ctlBody & "</p></BODY></HTML>"
.Send
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top