Outlook automation

Q

Question Boy

Hello,

In a db i am doing a simple outlook automation. in this particular case I
do not send the e-mail, I create it and make it visible to the user so they
can make mods if they so choose.

My problem/question is, the new outlook mail does not always take focus and
is sometimes hidden behind the db, or other apps, so the user does realize it
worked.... (you get the picture). Is there a way to force the focus onto the
newly created e-mail?

My Outlook Function is posted below for reference

Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim objOutlookRecip As Object
Dim objOutlookAttach As Object

On Error GoTo ErrorMsgs

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add(strTo)
objOutlookRecip.Type = 1

If Not IsMissing(strBCC) Then
' Add the BCC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strBCC)
objOutlookRecip.Type = 3
End If


' Set the Subject, Body, and Importance of the message.
.Subject = strSubject
.Body = strBody
.Importance = 2 '2=High importance \1=Normal \ 0=Low

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
If IsArray(AttachmentPath) Then
For i = LBound(AttachmentPath) To UBound(AttachmentPath) - 1
If AttachmentPath(i) <> "" And AttachmentPath(i) <> "False" Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath(i))
End If
Next i
Else
If AttachmentPath <> "" And AttachmentPath(i) <> "False" Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
End If
End If

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next

If bEdit Then 'Choose btw transparent send and preview send
.Display
Else
.Send
End If
End With

Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing


Thank you,

QB
 

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