Cant send user edited message cleanly

T

tcmill

All

My code generates a message that is presented to the user who selects
the approprite person to sent to & reviews the mesasge before manually
sending it

The problem is when they hit sent it sits in the outbox so I added the
following lines thanks to
Dimitri which will sent the message provided the explorer window is
open.

Set btn = objExplorer.CommandBars.FindControl(1, 7095)
btn.Execute

Altho the user has not hit sent by the time these 2 lines are executed
they seem to do the trick


The problem is the user is left with the explorer window open after the
message is sent
The problem exists with ot without the use of redemption

Does anyone have some code that when the users initiates the send it
sends Ok
Or else how can I clean up the explorer window after which is left
open
I am using outlook 2003 with exchange

Many Thanks

Tony


The Code

Dim objOutlook As Object
Dim objOutlookMsg As Object
Dim objOutlookRecip As Object
Dim NS As Object
Dim objInbox As Object
Dim objExplorer As Object
Dim objRedempMsg As Object
Dim btn As Object


' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

'Logon to MAPI
Set NS = objOutlook.GetNamespace("MAPI")
NS.Logon

'this is required to get Outlook to send else it sits in the outbox
after the users hits send
'need to expose the explorer window before doing a sendkey later
Set objInbox = NS.GetDefaultFolder(olFolderInbox)
Set objExplorer = objOutlook.Explorers.Add(objInbox,
olFolderDisplayNormal)
objExplorer.Display
objExplorer.WindowState = olMinimized


' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)


'Create Redemption Safe Mail - library Redemption.dll
Set objRedempMsg = CreateObject("Redemption.SafeMailItem")

'Point the message to Redemption
objRedempMsg.Item = objOutlookMsg



strrecipient = "John Brown"



Dim strBody As String

strBody = "Attached please find a Memo which initiates a Non
Conformance."
With objRedempMsg

Set objOutlookRecip = .Recipients.Add(strrecipient)

objOutlookRecip.Type = olTo

.Subject = "A New Non Conformance has been raised - OUTLOOK TEST
ONLY "
.Body = strBody

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


.Display

End With



'Need to force the send at times outlook explorer needs to be
visible
Set btn = objExplorer.CommandBars.FindControl(1, 7095)
btn.Execute




ExitProc:
'Set objOutlookMsg = Nothing
Set objOutlook = Nothing
'Set objOutlookRecip = Nothing
 
G

Guest

Call the Explorer.Close method when you are done with it, and set your
Explorer variable to nothing to clean up.
 

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