PARAMETERS pc_attachmentname, pc_subject, ; pc_mailtext, pc_addresslist LOCAL trycount loMail = NEWOBJECT("lf_cdomail","cdomaillib") WITH loMail *-- Create error collection .oErrors = CREATEOBJECT("Collection") .cServer = oApp.gc_smtpserver .nServerPort = oApp.ln_cdoserport *-- Use SSL connection .lUseSSL = oApp.ll_cdousessl .nConnectionTimeout = oApp.ln_cdotimeout && Default 30 sec's *-- Do not use cache for cHtmlBodyUrl .lURLGetLatestVersion = oApp.ll_cdogetver *-- Use SMTP Server Port .nSendUsingPort = oApp.ln_cdouseport *-- The following lines are required * if your SMTP server requires basic authentication .nAuthenticate = oApp.ln_cdoauthen .cUserName = oApp.gc_smtpuser .cPassword = oApp.gc_smtppass .cFrom = oApp.gc_smtpfrom *-- Use use testaddr for mail testing IF oApp.gl_mailtest .cTo = oApp.gc_testaddr ELSE .cTo = pc_addresslist ENDIF .cCC = "" .cBCC = "" .cHtmlBody = "" .cAttachment = "" *-- Attachments are optional Comment this line out if there are no attachments IF NOT EMPTY(pc_attachmentname) .cAttachment = pc_attachmentname ENDIF .cSubject = pc_subject .cHtmlBody = pc_mailtext .cTextBody = pc_mailtext trycount =1 DO WHILE trycount < 4 IF .Send() <> 0 AND trycount = 3 DO notice WITH "Mail Sending Error" EXIT ELSE EXIT ENDIF trycount = trycount +1 ENDDO ENDWITH RELEASE loMail RETURN>>"Connection Rejected"
>>SendCDOMail() >> >> >>FUNCTION SendCDOMail() >>SET STEP ON >> LOCAL loCDOMesage AS CDO.Message >> LOCAL loCDOConfig AS CDO.Configuration >> >> lcSchema = [http://schemas.microsoft.com/cdo/configuration/] >> loCDOConfig = CREATEOBJECT([CDO.Configuration]) >> WITH loCDOConfig.FIELDS >> .ITEM(lcSchema + [smtpserverport]) = 25 >> .ITEM(lcSchema + [sendusing]) = 2 >> .ITEM(lcSchema + [smtpserver]) = "smtp.freesmtpservers.com" >> .ITEM(lcSchema + [smtpauthenticate]) = 0 >> .ITEM(lcSchema + [sendusername]) = "" >> .ITEM(lcSchema + [sendpassword]) = "" >> .ITEM(lcSchema + [smtpusessl]) = .f. >> .UPDATE() >> ENDWITH >> loCDOMesage = CREATEOBJECT([CDO.Message]) >> loCDOMesage.Configuration = m.loCDOConfig >> loCDOMesage.BodyPart.Charset = "utf-8" >> >> WITH loCDOMesage >> .From = "from@somemail.com" >> .To = "to@somemail.com" >> .Subject = "This is a test" >> .HTMLBody = "Test of the body contets" >> .HTMLBodyPart.Charset = "utf-8" >> .TextBodyPart.Charset = "utf-8" >> TRY >> .Send() >> CATCH TO oError >> MesageBox(oError.Message) >> ENDTRY >> ENDWITH >> >> loCDOMesage = NULL >> loCDOConfig = NULL >> RELEASE loCDOConfig, loCDOMesage >>RETURN "" >>>>
>>>loEmail = CREATEOBJECT('Email') >>>loEmail.Subject = 'This is a test' >>>loEmail.Body = [Here's some content.] >>>loEmail.From = 'tamar@istesting.com' >>>?loEmail.AddTo('tamar@didthiswork.com') >>> >>>loMailMan = CREATEOBJECT('MailMan') >>>loMailman.smtphost = 'smtp.freesmtpservers.com' >>>loMailman.smtpport = 25 >>>?loMailman.Sendemail(loEmail) >>>_cliptext = loMailMan.lasterrortext >>>>>>
>>>ChilkatLog: >>> SendEmail: >>> DllDate: Oct 27 2023 >>> ChilkatVersion: 9.5.0.96 >>> UnlockStatus: 0 >>> Architecture: Little Endian; 32-bit >>> Language: ActiveX >>> VerboseLogging: 0 >>> Auto unlock for 30-day trial >>> UnlockStatusMsg: Unlocked for 30-day trial >>> UnlockStatus: 1 >>> sendEmailInner: >>> ReadTimeout: 30000 >>> renderToMime_pt1: >>> createEmailForSending: >>> Auto-generating Message-ID >>> --createEmailForSending >>> --renderToMime_pt1 >>> sendMimeInner: >>> ensureSmtpSession: >>> ensureSmtpConnection: >>> smtpParams: >>> SmtpHost: smtp.freesmtpservers.com >>> SmtpPort: 25 >>> SmtpUsername: >>> SmtpSsl: 0 >>> StartTLS: 0 >>> --smtpParams >>> smtpConnect: >>> smtpHostname: smtp.freesmtpservers.com >>> smtpPort: 25 >>> connectionIsReady: >>> SMTP host changed. >>> Need new SMTP connection... >>> --connectionIsReady >>> smtpSocketConnect: >>> socket2Connect: >>> connect2: >>> connectSocket_v2: >>> connect_domain: >>> Connection attempt failed. >>> maxWaitTimeMs: 30000 >>> totalMsWaitedSoFar: 17550 >>> Failed. >>> --connect_domain >>> --connectSocket_v2 >>> ConnectFailReason: Connection rejected >>> A few possible causes for a connection being rejected are: >>> - A firewall (software or hardware), such as Windows Firewall, is blocking the connection . >>> - Nothing is listening at the remote host:port >>> --connect2 >>> --socket2Connect >>> Failed to connect to SMTP server.. >>> --smtpSocketConnect >>> --smtpConnect >>> --ensureSmtpConnection >>> --ensureSmtpSession >>> --sendMimeInner >>> --sendEmailInner >>> Failed. >>> --SendEmail >>>--ChilkatLog >>>>>>