Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
FUNCTION SECUREEMAIL
PARAMETERS m.SMTPSERVER,m.SMTPNAME,m.SMTPUSERNAME,m.SMTPPASSWORD,m.RECIPIENT,m.SUBJECT,m.BODY,m.SMTPPORT,m.ATTFILE,m.ATTFILE2,M.HTMLBODY
PRIVATE m.SMTPSERVER,m.SMTPNAME,m.SMTPUSERNAME,m.SMTPPASSWORD,m.RECIPIENT,m.SUBJECT,m.BODY,M.SMTPPORT, m.ATTFILE,m.ATTFILE2,I
LOCAL LOMAILMAN, LOEMAIL,LNSUCCESS
IF PCOUNT() < 11
m.HTMLBODY = .F.
ENDIF
IF PCOUNT() < 10
m.ATTFILE2 = ""
ENDIF
IF PCOUNT() < 9
m.ATTFILE = ""
ENDIF
m.SMTPNAME = STRTRAN(m.SMTPNAME,";",",")
m.RECIPIENT = STRTRAN(m.RECIPIENT,";",",")
* The mailman object is used for sending and receiving email.
LOMAILMAN = CREATEOBJECT('Chilkat_9_5_0.MailMan')
* Any string argument automatically begins the 30-day trial.
LNSUCCESS = LOMAILMAN.UNLOCKCOMPONENT("secretcodehere")
IF (LNSUCCESS <> 1) THEN
MESSAGEBOX(LOMAILMAN.LASTERRORTEXT,48,"Problem")
ELSE
LOMAILMAN.SMTPHOST = m.SMTPSERVER
LOMAILMAN.SMTPUSERNAME = m.SMTPUSERNAME
LOMAILMAN.SMTPPASSWORD = m.SMTPPASSWORD
LOMAILMAN.SMTPSSL = 0
LOMAILMAN.STARTTLS = 1
LOMAILMAN.SMTPPORT = m.SMTPPORT
LOEMAIL = CREATEOBJECT("Chilkat_9_5_0.Email")
loemail.Charset = "utf-8"
LOEMAIL.FROM = m.SMTPNAME
IF !","$m.RECIPIENT .and. !m.CRLF$m.RECIPIENT .and. !";"$m.RECIPIENT
LOEMAIL.ADDTO(m.RECIPIENT,m.RECIPIENT)
ELSE
M.RECIPIENT = STRTRAN(STRTRAN(M.RECIPIENT, ',', M.CRLF),";",m.CRLF)
FOR I=1 to MEMLINES(M.RECIPIENT)
IF "@"$MLINE(M.RECIPIENT,I)
LOEMAIL.ADDTO(MLINE(m.RECIPIENT,I),MLINE(m.RECIPIENT,I))
ENDIF
ENDFOR
ENDIF
IF !M.HTMLBODY
loEmail.AddPlainTextAlternativeBody(m.Body)
ELSE
loEmail.AddHtmlAlternativeBody(m.Body)
ENDIF
LOEMAIL.SUBJECT = m.SUBJECT
IF !EMPTY(m.AttFile)
loEmail.AddFileAttachment(m.AttFile)
ENDIF
IF !EMPTY(m.AttFile2)
loEmail.AddFileAttachment(m.AttFile2)
ENDIF
WAIT "Sending... Please Wait" WINDOW NOWAIT TIMEOUT 10
LOMAILMAN.OPENSMTPCONNECTION()
LLRESULT = LOMAILMAN.SENDEMAIL(LOEMAIL)
WAIT CLEAR
IF LLRESULT <> 1
DO CASE
CASE LEFT(ALLTRIM(LOMAILMAN.LASTERRORTEXT),3)= "-3 "
MESSAGEBOX("Problem Occurred during Test:"+m.CRLF+m.CRLF+LOMAILMAN.LASTERRORTEXT+m.CRLF+m.CRLF+;
"THIS PROBLEM GENERALLY MEANS THE NAME OF THE SMTP SERVER IS NOT CORRECT, IT IS NOT CURRENTLY RUNNING OR NOT VISIBLE FROM THIS WORKSTATION."+m.CRLF+m.CRLF+;
"THIS CAN SOMETIMES BE CAUSED BY ENTHUSIASTIC ANTI-VIRUS SOFTWARE - TRYING TO STOP SPAM BEING SENT FROM YOUR PC.",48,"Problem")
CASE LEFT(ALLTRIM(LOMAILMAN.LASTERRORTEXT),3)= "500"
MESSAGEBOX("Problem Occurred during Test:"+m.CRLF+m.CRLF+LOMAILMAN.LASTERRORTEXT+m.CRLF+m.CRLF+;
"THIS PROBLEM GENERALLY MEANS THE SMTP SERVER IS CONFIGURED NOT TO ACCEPT E-MAILS FOR THE SPECIFIED RECIPIENT (OR THEIR DOMAIN [THE XXX.COM BIT]."+m.CRLF+m.CRLF+;
"YOU WILL PROBABLY NEED TO GET THE SMTP SERVER'S ADMINISTRATOR TO HELP YOU.",48,"Problem")
CASE LEFT(ALLTRIM(LOMAILMAN.LASTERRORTEXT),3)= "530"
MESSAGEBOX("Problem Occurred during Test:"+m.CRLF+m.CRLF+LOMAILMAN.LASTERRORTEXT+m.CRLF+m.CRLF+;
"THIS PROBLEM GENERALLY MEANS THE SMTP SERVER IS CONFIGURED TO EXPECT AUTHENTICATION."+m.CRLF+m.CRLF+;
"YOU WILL PROBABLY NEED TO GET A USERNAME AND A PASSWORD FROM THE SMTP SERVER'S ADMINISTRATOR.",48,"Problem")
CASE LEFT(ALLTRIM(LOMAILMAN.LASTERRORTEXT),3)= "535"
MESSAGEBOX("Problem Occurred during Test:"+m.CRLF+m.CRLF+LOMAILMAN.LASTERRORTEXT+m.CRLF+m.CRLF+;
"YOU HAVE PROBABLY ENTERED YOUR SMTP SERVER USERNAME OR PASSWORD INCORRECTLY."+m.CRLF+m.CRLF+;
"YOU SHOULD CHECK THEM - THEY MAY BE CASE SENSITIVE.",48,"Problem",200)
CASE LEFT(ALLTRIM(LOMAILMAN.LASTERRORTEXT),3)= "550"
MESSAGEBOX("Problem Occurred during Test:"+m.CRLF+m.CRLF+LOMAILMAN.LASTERRORTEXT+m.CRLF+m.CRLF+;
"THIS PROBLEM GENERALLY MEANS THE SMTP SERVER IS NOT SET-UP TO ACCEPT E-MAILS FROM THIS WORKSTATION."+m.CRLF+m.CRLF+;
"YOU WILL PROBABLY NEED TO GET THE SMTP SERVER'S ADMINISTRATOR TO HELP YOU.",48,"Problem")
OTHERWISE
_CLIPTEXT=LOMAILMAN.LASTERRORTEXT
MESSAGEBOX("Problem Occurred during Test:"+m.CRLF+m.CRLF+LOMAILMAN.LASTERRORTEXT,48,"Unexpected Problem")
ENDCASE
ENDIF
LNSUCCESS = LOMAILMAN.CLOSESMTPCONNECTION()
IF (LNSUCCESS <> 1) THEN
MESSAGEBOX( "Connection to SMTP server not closed cleanly.",48,"Problem")
ENDIF
RELEASE LOEMAIL
ENDIF
RELEASE LOMAILMAN
RETURN(.T.)
* The below is intended for use with the the OUTLOOK application
USE MYTABLE SHARED
GO myrecno
oOutlook = Createobject('Outlook.Application')
oNameSpace = oOutlook.getnamespace('MAPI')
oOutbox = oNameSpace.GetDefaultFolder(4)
oItems = oOutbox.Items
oMailItem = oItems.Add(0)
oMailItem.To = ALLTRIM(EMAIL)
oMailItem.Subject = TRIM(SUBJECT)
oMailItem.Body = "Whatever your message is here"+ ;
CHR(13)+CHR(13)+"Next line if required"
oMailItem.attachments.add(\myfiles\filename.pdf)
oMailItem.ReadReceiptRequested = .T. && Request a READ receipt
* oMailItem.Display && Display the email before you send it
* oMailItem.Send && Send the email without viewing it
DECLARE integer ShellExecute IN shell32.dll ;
integer hndWin, string cAction, string cFileName, ;
string cParams, string cDir, integer nShowWin
LOCAL lcEmail
*!* Replace the email addy below with a valid one
lcEmail = "mailto:somewhere@somehost.com?Subject=Testing+ShellExecute+For+Email&Body=Hello+World!"
ShellExecute(0,"open",lcEMail,"","",1)