DAVID POWELL
Senior Member
- Outlook version
- Outlook 2010 32 bit
- Email Account
- Exchange Server
I have vba code that sends emails.
does just fine.
Then i want to quit Outlook.
Application.Quit
Until in my code I want to close outlook after sending them.
I used this bit of code to rush and execute the send/receive, thinking it would force the outbox stuff to send.
but I keep getting the message "You have unsent emails..." counting down 30 seconds...
----------------------------------------------------------------------------------------------------------------------------------
Function Item_Open()
Dim strForm As String
Dim objFolder As Folder
Dim objItem As Outlook.MailItem
'Dim objRecip As Recipient
Dim strBcc As String
Dim objMail As Outlook.MailItem
Dim objRecip As Outlook.Recipient
Dim mySyncObjects As Outlook.SyncObjects
Dim syc As Outlook.SyncObject
'strBcc = "xxx.xxxx@xxxx.com"
strForm = "IPM.Note.proposalm"
Set objFolder = _
Application.ActiveExplorer.CurrentFolder
Set objItem = _
objFolder.Items.Add(strForm)
objItem.To = "xxxx.xxxx@xxx.com"
Set objRecip = objItem.Recipients.Add(strBcc)
objRecip.Resolve
If objRecip.Resolved Then
objRecip.Type = olBCC ' 3
End If
objItem.Subject = "Proposal Survey. Please Respond."
objItem.Send
' objItem.Display
Item_Open = True
' force the emails out of outbox ?
Set mySyncObjects = Application.GetNamespace("MAPI").SyncObjects
Set syc = mySyncObjects("All Accounts")
syc.Start
Sleep (10000)
Application.Quit
End Function
does just fine.
Then i want to quit Outlook.
Application.Quit
Until in my code I want to close outlook after sending them.
I used this bit of code to rush and execute the send/receive, thinking it would force the outbox stuff to send.
but I keep getting the message "You have unsent emails..." counting down 30 seconds...
----------------------------------------------------------------------------------------------------------------------------------
Function Item_Open()
Dim strForm As String
Dim objFolder As Folder
Dim objItem As Outlook.MailItem
'Dim objRecip As Recipient
Dim strBcc As String
Dim objMail As Outlook.MailItem
Dim objRecip As Outlook.Recipient
Dim mySyncObjects As Outlook.SyncObjects
Dim syc As Outlook.SyncObject
'strBcc = "xxx.xxxx@xxxx.com"
strForm = "IPM.Note.proposalm"
Set objFolder = _
Application.ActiveExplorer.CurrentFolder
Set objItem = _
objFolder.Items.Add(strForm)
objItem.To = "xxxx.xxxx@xxx.com"
Set objRecip = objItem.Recipients.Add(strBcc)
objRecip.Resolve
If objRecip.Resolved Then
objRecip.Type = olBCC ' 3
End If
objItem.Subject = "Proposal Survey. Please Respond."
objItem.Send
' objItem.Display
Item_Open = True
' force the emails out of outbox ?
Set mySyncObjects = Application.GetNamespace("MAPI").SyncObjects
Set syc = mySyncObjects("All Accounts")
syc.Start
Sleep (10000)
Application.Quit
End Function