Ok, the email body is long, about 50,000 characters. I have had a successful email sent that was 133,000 characters though.
I've printed the string in the immediate window when the function crashes, which is equivalent to debug.print, copied that into a text editor, saved it as an html file, and run it through IE8. It works fine. I have searched the string for ", there are none.
The loop works like this:
I cycle through some data and build the HTML string that is relevant for the recipient, collect the recipients email address and then send it, and clear out the HTML string. There will be a maximum of 6 receipients.
I thought the article you found may have hit the nail on the head, however, as when I was copying HTMLBody into sublime text, there were carriage returns midway through urls, or tags. The whole thing worked fine once, but then I've had the same error every time after that.
Now I'm trying with no variables whatsoever, and it fails, the third pass. Here is the code that is failing:
Code:
cdoObj.Subject = "Products needing attention 1"
cdoObj.HTMLBody = "" 'emailStyle & HTMLBody
'cdoObj.To = emailTo
cdoObj.CC = "andrew.sharpe@rbstar.co.uk"
cdoObj.from = "itdept@rbstar.co.uk"
cdoObj.send
To be 100% clear, this works twice, and then fails on the third pass. I can see nothing that changes - of course, the string contents themselves have changes, but they are not included.