Close Oulook after sending emails via vba without outbox getting stuck.

Status
Not open for further replies.

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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
O Outlook 365 - Toolbar - Close all items - missing? Using Outlook 3
K Working with Explorer.Close event Outlook VBA and Custom Forms 3
Diane Poremsky How to Compact the Data File When you Close Outlook Using Outlook 0
Diane Poremsky Close a Meeting When the Room is Full Using Outlook 0
L Gmail POP, Android IMAP, Outlook 2013 setup close Using Outlook 5
D help with Item/Inspector close event Outlook VBA and Custom Forms 1
D RUN SCRIPT WHEN OUTLOOK IS CLOSE Outlook VBA and Custom Forms 1
F Automatically close email after selecting mark unread Using Outlook 1
S Pop up reminder while i close outlook Outlook VBA and Custom Forms 5
Y (Shared Folder) Using the preview pane to open and close a fax, without opening the email itself Using Outlook 1
C Open/Close Outlook - Via Excel VBA Using Outlook 2
J OL wont close after VB app runs Using Outlook 17
Q Looking for Outlook 2010 Close Event Id Exchange Server Administration 1
R Can't close Personal Folders after switching to Exchange 2010 Using Outlook 2
R Outlook and google calendar stuck if I close outlook Using Outlook 1
J Messages close themselves - Outlook 2007 Using Outlook 1
P Minimize button causes Outlook to close 2007 Using Outlook 1
D Cannot Close pst file Using Outlook 1
K The file c:\...\Outlook1.pst cannot be accessed because another workstation has modified it. Close a Using Outlook 2
R Outlook 2003 - Close parent form before opening child form Outlook VBA and Custom Forms 4
S Error 287 on Inspector.Close() Outlook VBA and Custom Forms 4
D Macro to Close Open Messages Outlook VBA and Custom Forms 3
E How to know if a Form.Close Event is the result of canceling Outlook VBA and Custom Forms 3
Q Why is BCM causing Outlook to close? BCM (Business Contact Manager) 2
V Move email using the Close event Outlook VBA and Custom Forms 11
R Close item Outlook VBA and Custom Forms 4
U Re: MailItem.Close() Outlook VBA and Custom Forms 1
H Outlook Does Not Really Close When I Close It BCM (Business Contact Manager) 1
P Oulook addin unloaded in office 2007 Outlook VBA and Custom Forms 2
M Following a refresh of computer (win8.0) conflicting oulook accounts Using Outlook 2
R Copy additional IMAP accounts into Oulook 365 Account Exchange Server Administration 4
F Difficult Oulook Crashing Problem Using Outlook 1
S Oulook view settings ( NO PST) Using Outlook 0
L Oulook Size On a Desktop Screen Using Outlook 2
L Oulook always "disconnected" how do I keep it open all of the time? Using Outlook 1
P Oulook 2010 very slow Using Outlook 2
P Problem: Favorites not persisting. (Oulook 2010) Using Outlook 1
J Oulook 2010 Shared Calendar Syncing Using Outlook 1
L Oulook 2003 Form upgraded to 2007 Outlook VBA and Custom Forms 3
M Messages Intermittently Dont Arrive In Sent Items After Sending Successfully Using Outlook 4
O Outlook on Android: after sharing / sending a news article, draft remains open. Why? Using Outlook 1
P Sending email from outlook IMAP to GMAIL where embedded images are added as attachment Using Outlook 1
V Form data not sending for some users Outlook VBA and Custom Forms 2
L isn't there an OL add-on that flags addressee before sending Using Outlook 3
R Microsoft Outlook 2016 - Gmail not sending, asks for password for SMTP, tried different ports Using Outlook 23
A Flag Message for Follow Up after sending Outlook VBA and Custom Forms 1
D Sending email from Office 365 alias in Outlook Using Outlook 3
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
L unblocking attachments before sending Office 365 Advanced Protection Using Outlook 0
B Outlook 2003 email sending & receiving suddenly stopped working Using Outlook 3

Similar threads

Top