Outlook Interop Mass Email
I have an App that does mass emails. It uses a spreadsheet with an email column to accomplish this. It works fine except for...
After some varying amounts of emails have been sent the Outbox folder starts filling up. The App continues to run until it is done.
If we go to Outlook and press send/receive nothing happens.
If we close Outlook and exit without sending it Looks like Outlook has quit, but you can't restart it until you use Task Manager to kill the Outlook Task.
Upon restarting outlook sends the remainder of the emails.
What am I doing wrong?
Re: Outlook Interop Mass Email
You may not actually be doing anything "wrong", at least from your coding perspective. It is possible that your ISP has s limit to the amount of e-mails sent in a given period of time to prevent spammers from getting them on a blacklist. This is assuming that you are sending external emails. If this entirely an internal e-mail system, then there may be an Exchange Server setting that also controls this, or some similar setting if you are using a different system. More details on how Outlook is actually sending the emails would be helpful.
It is also possible that Outlook is having issues with too many submitted emails at once. A way to test this would be to introduce a variable delay between sending each email. Test with a 10, 30, and 60 second delay to see if the issue goes away.
Re: Outlook Interop Mass Email
Quote:
Originally Posted by
jdc2000
You may not actually be doing anything "wrong", at least from your coding perspective. It is possible that your ISP has s limit to the amount of e-mails sent in a given period of time to prevent spammers from getting them on a blacklist. This is assuming that you are sending external emails. If this entirely an internal e-mail system, then there may be an Exchange Server setting that also controls this, or some similar setting if you are using a different system. More details on how Outlook is actually sending the emails would be helpful.
It is also possible that Outlook is having issues with too many submitted emails at once. A way to test this would be to introduce a variable delay between sending each email. Test with a 10, 30, and 60 second delay to see if the issue goes away.
This is internal and there aren't any restrictions that I am aware of.
It looks like it has something to do with how fast and how many attachments(and size of attachments). I found this bit of code and it seems better, until the attachments get in the 1MB range.
Code:
' Application.DoEvents YUCK - but seems to help OutLook send
SendRecv()
For x As Integer = 1 To 3
Threading.Thread.Sleep(525)
Application.DoEvents()
Next
Code:
Private oNS As Outlook.NameSpace
Private oSyncs As Microsoft.Office.Interop.Outlook.SyncObjects
Private oSync As Microsoft.Office.Interop.Outlook.SyncObject
Private Sub SendRecv()
Try
' Reference SyncObjects.
oSyncs = oNS.SyncObjects
oSync = oSyncs.Item("All Accounts")
' Send and receive.
oSync.Start()
Catch ex As Exception
End Try
End Sub
Re: Outlook Interop Mass Email
Aha - attachments! I did not notice any mention of attachments to the mass emails in your first post. That explains a lot. Each of those attachments has to be uploaded to the mail server before the email can be sent. That is going to take additional time, and could be what is choking the email server. There needs to be a delay for each attachment, and that delay needs to correlate with the size of the attachment. If you attaching five attachments of 5 MB each, that is going to need a significant delay factor before you try sending the next email.