SendMail not working. Tried everything I found in documentation and forum. Need help.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SendMail not working. Tried everything I found in documentation and forum. Need help.
In gmail, 2-step verification is turned off.
Account access is enabled.
Less secure app access is turned on.
There is a log file here: C:\\TestLog\\Log.mht
The script I am using:
function Test() { SendEmail("xxxxn@gmail.com", "xxxx@xxxxxxxxx.com", "Test", "TestMessage", "C:\\TestLog\\Log.mht"); } function SendEmail(mFrom, mTo, mSubject, mBody, mAttachment) { var smtpServer = "smtp.gmail.com" //"smtp.gmail.com"; var smtpPort = 587; //tried 587, 465, 26 & 25 as well var userLogin = "xxxx"; // e.g. "abc" if the address is abc@gmail.com var userPassword = "PASSWORD"; var autentificationType = 1; // cdoBasic var connectionTimeout = 30; var useSSL = true;// Required by Gmail try { var schema = "http://schemas.microsoft.com/cdo/configuration/"; var mConfig = Sys.OleObject("CDO.Configuration"); mConfig.Fields.Item(schema + "sendusing") = 2; // cdoSendUsingPort mConfig.Fields.Item(schema + "smtpserver") = smtpServer; mConfig.Fields.Item(schema + "smtpserverport") = smtpPort; mConfig.Fields.Item(schema + "sendusername") = userLogin; mConfig.Fields.Item(schema + "sendpassword") = userPassword; mConfig.Fields.Item(schema + "smtpauthenticate") = autentificationType; mConfig.Fields.Item(schema + "smtpconnectiontimeout") = connectionTimeout; mConfig.Fields.Item(schema + "smtpusessl") = useSSL; mConfig.Fields.Update(); var mMessage = Sys.OleObject("CDO.Message"); mMessage.Configuration = mConfig; mMessage.From = mFrom; mMessage.To = mTo; mMessage.Subject = mSubject; mMessage.HTMLBody = mBody; if(0 < mAttachment.length) { mMessage.AddAttachment(mAttachment); } mMessage.Send(); } catch(exception) { Log.Error("E-mail cannot be sent", exception.description); return false; } Log.Message("Message to <" + mTo + "> was successfully sent"); return true; }
Log reports: 'E-mail cannot be sent', Additional Info panel is blank.
Help is much appreciated.
Dave
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Changed to 465, same error!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Basically, at this point, it's a connectivity problem. something is not allowing the link up between your machine and the gmail server. Some google searches seem to point to the port... that you might not have the correct port.
Since you're using SSL, it should be 465. The username should be your full gmail address including the @gmail.com
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have tried to use the entire email address (username@gmail.com) with port 465. That did not make any difference. I read that with gmail I need to use SSL, is that true?
I asked my manager if any of the ports in question are blocked, he was not sure. I need to talk to the network guys to make sure they are not blocked.
If you have any other solutions, I would love to hear it.
Once again, I really appreciate your time and effort trying to help me! Thank you!
Dave
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot for your help, @tristaanogre.
@royd, were you able to resolve the issue?
Tanya Yatskovskaya
SmartBear Community and Education Manager

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »