Messages stuck in Outlook 2003 outbox
-
I am sending emails through Outlook 2003. The problem I'm having is that the message goes into the outbox, but if the user's outlook isn't open, the message just stays in the outbox. Can I some how siently start outlook, and 'send/receive' all? Dim OutlookApplication As New Microsoft.Office.Interop.Outlook.Application Dim OutLookMailItem As Microsoft.Office.Interop.Outlook.MailItem Dim imailitem As Int32 = Microsoft.Office.Interop.Outlook.OlItemType.olMailItem OutLookMailItem = CType(OutlookApplication.CreateItem(imailitem), Microsoft.Office.Interop.Outlook.MailItem) 'Set To and Subject of the email. OutLookMailItem.Subject = cSubject OutLookMailItem.Attachments.Add(Me.emailDirPath + fname + cExtension) 'Display MailItem and let them fill in the rest! ' ' make it modal ' Me.Cursor = Cursors.Default OutLookMailItem.Display(True)
-
I am sending emails through Outlook 2003. The problem I'm having is that the message goes into the outbox, but if the user's outlook isn't open, the message just stays in the outbox. Can I some how siently start outlook, and 'send/receive' all? Dim OutlookApplication As New Microsoft.Office.Interop.Outlook.Application Dim OutLookMailItem As Microsoft.Office.Interop.Outlook.MailItem Dim imailitem As Int32 = Microsoft.Office.Interop.Outlook.OlItemType.olMailItem OutLookMailItem = CType(OutlookApplication.CreateItem(imailitem), Microsoft.Office.Interop.Outlook.MailItem) 'Set To and Subject of the email. OutLookMailItem.Subject = cSubject OutLookMailItem.Attachments.Add(Me.emailDirPath + fname + cExtension) 'Display MailItem and let them fill in the rest! ' ' make it modal ' Me.Cursor = Cursors.Default OutLookMailItem.Display(True)
Have you figured this out, or are you still having trouble with it?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
Have you figured this out, or are you still having trouble with it?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
I found the answer: Dim oApp As Microsoft.Office.Interop.Outlook._Application = New Microsoft.Office.Interop.Outlook.Application Dim oNS As Microsoft.Office.Interop.Outlook._NameSpace = oApp.GetNamespace("mapi") Dim oSyncs As Microsoft.Office.Interop.Outlook.SyncObjects Dim oSync As Microsoft.Office.Interop.Outlook.SyncObject Try ' Reference SyncObjects. oSyncs = oNS.SyncObjects oSync = oSyncs.Item("All Accounts") ' Send and receive. oSync.Start() Catch ex As Exception MessageBox.Show("oSync Error: " + ex.Message, "Error Sending Email From Outlook") End Try ' Clean up. oSync = Nothing oSyncs = Nothing oNS = Nothing oApp = Nothing