View Single Post
  #1  
Old January 17th 06, 08:22 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 4
Default Cant Send a displayed message without explorer open. Eric Legault & et al

Further top my last Post I'm still having problems getting the user
edited meassge to send

1. My code generates an email message which is displayed to the user

2.They edit the message add a recipient & hit send

3.It sits in the outbox italicized, not bold, and wont sent

So I wrapped the code with the following to force the sent (-Outlook
2003 with Exchange & redemption).It works but leaves an outlook
window open at the end

Set objInbox = NS.GetDefaultFolder(olFolderInbox)
Set objExplorer = objOutlook.Explorers.Add(objInbox,
olFolderDisplayNormal)
objExplorer.Display
objExplorer.WindowState = olMinimized
..
..
..Other code here
..


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


4. If I add
ObjExplorer.close
Set objexplorer = nothing

This will close outlook nicely but then the message wont sent

The next time I open outlook the message sends after a couple of
minutes.I assume by some exchange process


Questions

Is it possible to sent the email & still close down outlook
At the moment I can only sent it if an outlook window remains open

My code finishes before the user has clicked sent tho the force sent
click still seems to work

Do I open the wrong explorer window?

Many Thanks

Tony

The full code is as follows

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




Dim MyName As String

strTo = "


Dim strBody As String

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

Set objOutlookRecip = .Recipients.Add(strTo )


objOutlookRecip.Type = olTo

'Send the email to DCC
' Add the CC recipient(s) the DCC .
Set objOutlookRecip = .Recipients.Add("DCC")
objOutlookRecip.Type = olCC

.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

'objExplorer.Close



ExitProc:

Set objExplorer = Nothing
Set objOutlook = Nothing



'The word document running the code
Documents(SrcFile).Close False


Exit Sub

Ads