![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
Some suggestions:
- use the MailItem.Send method rather than executing a commandbar button - cancel the display of the e-mail if none of the recipients resolve and force the user to send manually - you don't need the Logon method - trap the SyncEnd method for a defined Send/Receive group to ensure that a forced send/receive completes before closing Outlook; use this code to force it: Public Sub SendReceiveNow() Dim oCtl As Office.CommandBarControl Dim oPop As Office.CommandBarPopup Dim oCB As Office.CommandBar 'Use the Send/Receive on All Accounts action in the Tools 'menu to send the items from the Outbox, and receive new items Set oCB = ActiveExplorer.CommandBars("Menu Bar") Set oPop = oCB.Controls("Tools") Set oPop = oPop.Controls("Send/Receive") Set oCtl = oPop.Controls("Send/Receive All") '("All Accounts") oCtl.Execute Set oCtl = Nothing Set oPop = Nothing Set oCB = Nothing End Sub -- Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ " wrote: 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 |
#3
|
|||
|
|||
![]()
Thanks Eric
Still no joy . I'll live with the outlook window left open after the code has run Eric Legault [MVP - Outlook] wrote: Some suggestions: - use the MailItem.Send method rather than executing a commandbar button - cancel the display of the e-mail if none of the recipients resolve and force the user to send manually - you don't need the Logon method - trap the SyncEnd method for a defined Send/Receive group to ensure that a forced send/receive completes before closing Outlook; use this code to force it: Public Sub SendReceiveNow() Dim oCtl As Office.CommandBarControl Dim oPop As Office.CommandBarPopup Dim oCB As Office.CommandBar 'Use the Send/Receive on All Accounts action in the Tools 'menu to send the items from the Outbox, and receive new items Set oCB = ActiveExplorer.CommandBars("Menu Bar") Set oPop = oCB.Controls("Tools") Set oPop = oPop.Controls("Send/Receive") Set oCtl = oPop.Controls("Send/Receive All") '("All Accounts") oCtl.Execute Set oCtl = Nothing Set oPop = Nothing Set oCB = Nothing End Sub -- Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ " wrote: 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 |
#4
|
|||
|
|||
![]()
If you're code is essentially calling Outlook to send a message and close it
down from an external application (not an Outlook COM Add-In or a VBA macro), then here's some "best practice" code that loads Outlook if necessary, or retrieves a handle to Outlook if it is already open. Outlook's state is important in regards to setting Explorer objects - you only need to create them if Outlook is closed. If you do create them, you have to make sure to close and destroy all objects so that Outlook can shut down properly: Dim objOL As Outlook.Application, blnNewOutlook As Boolean Dim objExp As Outlook.Explorer Dim objNS As Outlook.NameSpace Dim objMail As Outlook.MailItem 'Retrieve an existing Outlook Application object if it is already loaded Set objOL = GetObject(, "Outlook.Application") If objOL Is Nothing Then 'Outlook is closed; open it Set objOL = New Outlook.Application blnNewOutlook = True End If Set objNS = objOL.GetNamespace("MAPI") If blnNewOutlook = True Then Set objExp = objOL.Explorers.Add(objNS.GetDefaultFolder(olFolde rInbox), olFolderDisplayNormal) objExp.Activate 'Show Outlook Else ' Set objExp = objOL.ActiveExplorer End If Set objMail = objOL.CreateItem(olMailItem) objMail.Subject = "test" objMail.To = " objMail.Send Set objMail = Nothing If blnNewOutlook = True Then objExp.Close objOL.Quit End If Set objExp = Nothing Set objNS = Nothing Set objOL = Nothing -- Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ " wrote: Thanks Eric Still no joy . I'll live with the outlook window left open after the code has run Eric Legault [MVP - Outlook] wrote: Some suggestions: - use the MailItem.Send method rather than executing a commandbar button - cancel the display of the e-mail if none of the recipients resolve and force the user to send manually - you don't need the Logon method - trap the SyncEnd method for a defined Send/Receive group to ensure that a forced send/receive completes before closing Outlook; use this code to force it: Public Sub SendReceiveNow() Dim oCtl As Office.CommandBarControl Dim oPop As Office.CommandBarPopup Dim oCB As Office.CommandBar 'Use the Send/Receive on All Accounts action in the Tools 'menu to send the items from the Outbox, and receive new items Set oCB = ActiveExplorer.CommandBars("Menu Bar") Set oPop = oCB.Controls("Tools") Set oPop = oPop.Controls("Send/Receive") Set oCtl = oPop.Controls("Send/Receive All") '("All Accounts") oCtl.Execute Set oCtl = Nothing Set oPop = Nothing Set oCB = Nothing End Sub -- Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ " wrote: 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 |
#5
|
|||
|
|||
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
send a message to email 2 & 3 when selecting multiple contacts | Karen NZ | Outlook - Using Contacts | 9 | September 4th 06 05:04 PM |
Open EML file from Internet Explorer | Nathan | Outlook Express | 0 | March 8th 06 06:42 AM |
The Form Required to View this Message Can Not Be Displayed..somet | Angyl | Outlook - Using Forms | 4 | March 4th 06 01:23 AM |
How do I get OFFICE 97 to OPEN Internet explorer | Lost | Outlook - Installation | 1 | February 12th 06 07:22 AM |
Denied Outlook "Send" access via Explorer when DSL Yahoo service | Ken Steen-Olsen steen-olsen@sbcglobal | Outlook - Installation | 0 | January 12th 06 12:17 AM |