Reply to comment
Send email via Gmail account
Gmail SMTP server requires SSL connection on port 465.
Known Gmail limits on sending emails:
- An attachment size is limited to 25 MB
- An individual email can be sent to maximum of 100 recipients
- A large number of undeliverable messages could trigger an account lockdown
Exceeding any limits beside the attachment size will cause Gmail account to be locked down for 24-72 hours.
Sample code below uses CDO 2000 class for sending emails
| This is sample code. Add error handling and adjust to your requirements as necessary. |
* Replace addresses with real ones before running the code loMail = NEWOBJECT("Cdo2000", "Cdo2000.fxp") WITH loMail .cServer = "smtp.gmail.com" .nServerPort = 465 .lUseSSL = .T. .nAuthenticate = 1 && cdoBasic .cUserName = "yourGmailAccount@gmail.com" .cPassword = "yourGmailPassword" * If From address doesn't match any of the registered identities, * Gmail will replace it with your default Gmail address .cFrom = "yourGmailAccount@gmail.com" .cTo = "somebody@otherdomain.com, somebodyelse@otherdomain.com" .cSubject = "CDO 2000 email through Gmail SMTP server" * Uncomment next lines to send HTML body *.cHtmlBody = "<html><body><b>This is an HTML body<br>" + ; * "It'll be displayed by most email clients</b></body></html>" .cTextBody = "This is a text body." + CHR(13) + CHR(10) + ; "It'll be displayed if HTML body is not present or by text only email clients" * Attachments are optional * .cAttachment = "myreport.pdf, myspreadsheet.xls" ENDWITH IF loMail.Send() > 0 FOR i=1 TO loMail.GetErrorCount() ? i, loMail.Geterror(i) ENDFOR * Clear errors loMail.ClearErrors() ELSE ? "Email sent." ENDIF
See Also Send email with CDO 2000
Recent comments
1 week 4 days ago
4 weeks 19 hours ago
4 weeks 23 hours ago
4 weeks 1 day ago
4 weeks 1 day ago
5 weeks 2 days ago
8 weeks 2 days ago
10 weeks 4 days ago
12 weeks 2 days ago
12 weeks 3 days ago