Discussion:
The second send email is error
(too old to reply)
a***@gmail.com
2018-02-16 09:34:51 UTC
Permalink
Hi All,

The first send email is successfully sent but next send (For Each classes in data) is got error with message is The message could not be send to the SMTP server and bla bla. Please help me and below the script.

Dim data
data = split("C:\data\1.docx,C:\data\2.docx,C:\data\3.docx::C:\data\4.docx,C:\data\5.docx::C:\data\6.docx", "::")
sendNow

Sub sendNow ()
Set eObj = CreateObject("CDO.Message")

For Each classes in data
eObj.From = "***@test.com"
eObj.To = "***@tester.com"
eObj.Subject = hello
eObj.TextBody = hello

'Attach files
files = split(classes, ",")
For Each item in files
eObj.AddAttachment item
Next

Set eConfig = eObj.Configuration
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.tester.com"
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "***@tester.com"
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "tester"
eConfig.Fields.Update
eObj.Send
End Sub
Evertjan.
2018-02-16 10:04:50 UTC
Permalink
Post by a***@gmail.com
Hi All,
The first send email is successfully sent but next send (For Each
classes in data) is got error with message is The message could not be
send to the SMTP server and bla bla. Please help me and below the
script.
Dim data
data =
split("C:\data\1.docx,C:\data\2.docx,C:\data\3.docx::C:\data\4.docx,C:\da
ta\5.docx::C:\data\6.docx", "::") sendNow
Sub sendNow ()
debug = 0
Post by a***@gmail.com
Set eObj = CreateObject("CDO.Message")
For Each classes in data
debug = debug + 1
response.write "Debugging at 'For Each classes in data': " & n
Post by a***@gmail.com
eObj.Subject = hello
eObj.TextBody = hello
'Attach files
files = split(classes, ",")
For Each item in files
debug = debug + 1
response.write "Debugging at 'For Each item in files': " & n
Post by a***@gmail.com
eObj.AddAttachment item
Next
Set eConfig = eObj.Configuration
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpse
rver") = "smtp.tester.com"
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpse
rverport") = 465
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendus
ing") = 2
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpau
thenticate") = 1
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpus
essl") = true
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendus
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpa
ssword") = "tester" eConfig.Fields.Update
eObj.Send
End Sub
I see two different 'for each',
and only one 'next'!!!
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
R.Wieser
2018-02-16 10:28:31 UTC
Permalink
Andres,
Post by a***@gmail.com
Please help me and below the script.
That posted script is incomplete: the "For Each classes in data" line does
not seem to have a "next" associated to it.

As for the problem ? You probably need to put the creation of a message
object *inside* the above loop (starting a new message for each data array
entry).

Hope that helps.

Regards,
Rudy Wieser
a***@gmail.com
2018-02-16 12:25:45 UTC
Permalink
Post by R.Wieser
Andres,
Post by a***@gmail.com
Please help me and below the script.
That posted script is incomplete: the "For Each classes in data" line does
not seem to have a "next" associated to it.
As for the problem ? You probably need to put the creation of a message
object *inside* the above loop (starting a new message for each data array
entry).
Hope that helps.
Regards,
Rudy Wieser
You are correct, I just forget paste "Next" above posted. Please follow the error message screenshoot https://ibb.co/eP2ET7
a***@gmail.com
2018-02-16 13:26:35 UTC
Permalink
Post by a***@gmail.com
Post by R.Wieser
Andres,
Post by a***@gmail.com
Please help me and below the script.
That posted script is incomplete: the "For Each classes in data" line does
not seem to have a "next" associated to it.
As for the problem ? You probably need to put the creation of a message
object *inside* the above loop (starting a new message for each data array
entry).
Hope that helps.
Regards,
Rudy Wieser
You are correct, I just forget paste "Next" above posted. Please follow the error message screenshoot https://ibb.co/eP2ET7
Sorry I forget, for Line 37 is eObj.Send
R.Wieser
2018-02-16 13:38:24 UTC
Permalink
Andres,
Post by a***@gmail.com
I just forget paste "Next" above posted.
I *think* you need to put a bit more attention to what you're saying: There
is no "posted" in your code.

Also, I suggested to move the creation of the message object to another
spot, and see any indication that you tried. Ignoring suggestions but
still expecting help is definitily *not* the way to go. :-(


FYI, I removed the addition of attachments and all but the "smtpserver" and
"smtpserverport" configuration settings from your script (and set them to a
non-SSL SMTP server). All three messages got send (and received). In other
words, I cannot help you further (do not have any SSL SMTP set up).

Regards,
Rudy Wieser

P.s.
Basic bug-hunting:
Remove *everything* from your code thats not absolute neccessary and see if
it will work (like I removed the attachments and made the SMTP part as
basic as possible).
If it than does work start adding stuff bit-by-bit until you again get an
error. The problem is than most likely in the last-added part.
e***@gmail.com
2018-02-16 15:19:08 UTC
Permalink
Hi Rudy,

I am sorry, I am still dont understand whats exactly you mean. I mean incomplete posting like forget "Next". Iwas try put the debug but the debug is error. I am a beginner in VBS. Please correct my script please.

Dim data
data = split("C:\data\1.docx,C:\data\2.docx,C:\data\3.docx::C:\data\4.docx,C:\data\5.docx::C:\data\6.docx", "::")
sendNow

Sub sendNow ()
Set eObj = CreateObject("CDO.Message")

For Each classes in data
eObj.From = "***@test.com"
eObj.To = "***@tester.com"
eObj.Subject = hello
eObj.TextBody = hello

'Attach files
files = split(classes, ",")
For Each item in files
eObj.AddAttachment item
Next

Set eConfig = eObj.Configuration
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "***@gmail.com"
eConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "tester"
eConfig.Fields.Update
eObj.Send 'Here is the problem n=1 is work but next n is error. n (from For Each classes in data)
Next
End Sub


Thanks in advance!
e***@gmail.com
2018-02-16 18:31:10 UTC
Permalink
I am able to send a file of 10kb but unable to send 200kb file.
So, I got the problem is the attachment file size limit for SMTP server (smtp.gmail.com). Anyone idea for this please.

Thank you
JJ
2018-02-16 19:16:51 UTC
Permalink
Post by e***@gmail.com
I am able to send a file of 10kb but unable to send 200kb file.
So, I got the problem is the attachment file size limit for SMTP server
(smtp.gmail.com). Anyone idea for this please.
Thank you
It's not about attachment size, in this case. GMail's limit of attachment
size is 25MB. If an attachment size or the total size of all attachments is
greater than 25MB, GMail will move them into Google Drive and convert the
attachments into links. However, IIRC, if a Google user never accessed the
Google Drive service, GMail might reject the email.

JJ
2018-02-16 19:12:14 UTC
Permalink
Post by a***@gmail.com
Hi All,
The first send email is successfully sent but next send (For Each classes
in data) is got error with message is The message could not be send to
the SMTP server and bla bla. Please help me and below the script.
[snip]

First of all, a programmer should **never** ignore an error message.

As stated on the error message screenshot which you later posted, it says
"...message content and attachment content guildlines". It means that GMail
rejected your email because one or more of your attachments' or message
contents. Chances are that the attached document(s) contains a macro which
triggers GMail's anti virus.
Loading...