Sending 300 emails using Access 2013 (1 Viewer)

JohnPapa

Registered User.
Local time
Today, 13:15
Joined
Aug 15, 2010
Messages
954
@Doc
I agree with the previous comments. You can definitely open more than one copy of Outlook at once.

What you can't do is have two different versions of Outlook installed on the same PC.
I have both Office 2010 & 365 installed on this PC and have two versions of Access, Word, Excel etc but it won't let you do that with Outlook

@JohnPapa
Have you looked at the CDO help file yet. This is the relevant part:

View attachment 81982
You need to swop your SendUsing setting from 1 to 2 (or vice versa)

I tried all options without success. Maybe I do not have the correct Port and or Email Server information.
 

Micron

AWF VIP
Local time
Today, 07:15
Joined
Oct 20, 2018
Messages
3,476
I think that comment refers to CDO, so...
When at work and creating an email function using CDO I got the port and server info from a message header. In my case it seemed there were two possibilities (can't recall why) but one of them eventually worked. Did you look at message headers for that info?

EDIT - It occurred to me that you might be running into a server side time out for when one person is sending too many emails at once. Maybe contact your IT to see if one exists and what the value is then use that to break the tasks into chunks, i.e. send a batch, wait 15 minutes (or just less than whatever the time out is), send another batch, etc. The batch size will also be governed by the time out rules. I don't know if you would experience a time out using CDO or not, but I don't see why not. The same reasons for having time outs should apply regardless of how the server is used, but that's speculation on my part.
 
Last edited:

zeroaccess

Active member
Local time
Today, 06:15
Joined
Jan 30, 2020
Messages
671
What domain are the recipients on? Unless I missed it, you never specified. Are they internal, exchange server addresses, or are any of them external, like Gmail? That can really change things.
 

isladogs

MVP / VIP
Local time
Today, 11:15
Joined
Jan 14, 2017
Messages
18,186
I tried all options without success. Maybe I do not have the correct Port and or Email Server information.
That's exactly the point. You need to get the email settings for your account. Look at the account settings in Outlook,
If its a GMail account there's an extra step to do -see the last page of the Help file for that.

As already mentioned the CDO Help file contains a complete list of all error messages seen if any email settings are incorrect
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:15
Joined
Feb 28, 2001
Messages
26,996
Guys, in earlier versions of Office, I ran into issues with multiple instances of Outlook. If it works now, great, but I know for an absolute and incontrovertible fact that this was not always the case. I'm glad to hear that problem got fixed, but at the same time it just changes one problem for another. Now, you can litter memory with extra instances of Outlook just like you can with Excel. I almost think that if it WAS fixed, it was the wrong decision.
 

JohnPapa

Registered User.
Local time
Today, 13:15
Joined
Aug 15, 2010
Messages
954
That's exactly the point. You need to get the email settings for your account. Look at the account settings in Outlook,
If its a GMail account there's an extra step to do -see the last page of the Help file for that.

As already mentioned the CDO Help file contains a complete list of all error messages seen if any email settings are incorrect

I use Outlook for email communication and I had looked at the settings. I got the error ending in 58 and but the parameter changing did not help.
 

isladogs

MVP / VIP
Local time
Today, 11:15
Joined
Jan 14, 2017
Messages
18,186
After you changed that setting, did another error occur? If so, did you follow that up as well?
 

JohnPapa

Registered User.
Local time
Today, 13:15
Joined
Aug 15, 2010
Messages
954
The 300+ emails were sent successfully. It just took some time for the email to exit Outlook's Outbox. To avoid cramming a lot of emails on the Outbox a 10 sec delay was added which ensured that not more than one email was in the Outbox at the same time.

The code for sending the emails looks something like this

Private Sub SendEmail4(strTo As String, strAttachment As String)
Dim olApp As Object
Dim olMail As Object

On Error GoTo ErrorH
'Creates the memory for email objects
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(olMailItem)
'Generates email information
With olMail
'olFormatPlain is easier to type in an email with, my opinion only, this line is not needed
.BodyFormat = olFormatPlain
'Who the email is going to, using the strList created during loop above
.To = strTo
.cc = ""
.BCC = ""
.Subject = "Pay Slp"
.Body = "This is the body"
'Attaches the exported file using the variable created at beginning
.Attachments.Add strAttachment, olByValue, 1, Mid(strAttachment, 16, Len(strAttachment) - 15)

'.display 'Use for testing purposes only
.Send
End With
'Frees email objects stored in memory
Set olMail = Nothing
Set olApp = Nothing
EndCode:
Exit Sub
'Error handler to display error infor in message box, resumes end code
'Change is you want/need this to handle specific error numbers
ErrorH:
MsgBox Err.Number & " - " & Err.Description
Resume EndCode
End Sub
 

Micron

AWF VIP
Local time
Today, 07:15
Joined
Oct 20, 2018
Messages
3,476
As per post 9: P.S. Please use code tags (post toolbar) with proper indentation for more than a few lines of code.

I think I said this before in this thread but not sure - if you error out, there is no cleanup. I guess you must be calling this multiple times. Might always be OK, but since you're not doing the send in a loop in this code, if you do err out, another instance (or multiple) of Outlook may be lurking in your Task Manager.
 

Users who are viewing this thread

Top Bottom