html in email not working

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
hynan
Posts: 25
Joined: Sat Jun 29, 2013 7:00 pm

html in email not working

Post by hynan »

Hi all,

/*
little sample to send mails via SMTP Protocol
coded by Marek Olszewski, MOL-Systemy Komputerowe mol@pro.onet.pl http://www.molsystemy.pl" onclick="window.open(this.href);return false;
date of creation: 2011.11.01
you can change everything if you need!!!
happy testing !!!

aFiles -> Optional. Array of attachments to the email to send
if html used : cBody := Memoread( cData )
You can call it with parameters:
/I name_of_ini_file
/A attachment_file
*/
Thanks Mol for it
works good for Plain text without SSL

LOCAL eol := chr(13)+chr(10)
LOCAL aAttachments := {}
LOCAL TMP

LOCAL cIniFile := STRTRAN ( M->DEFPAD, "pizzapro", "sendmail" ) + "sendmail.ini"
LOCAL oMail, cData, i, oAttach
LOCAL cSubject := "" // -> Optional. Subject of the sending email
LOCAL cBody := "" // -> Optional. The body message of the email as text, or the filename of the HTML message to send.
LOCAL cTo := "" // -> Required. Character string or array of email addresses to send the email to
LOCAL cFrom := "" // -> Required. Email address of the sender
LOCAL cSMTPServer := "" // -> Required. IP or domain name of the mail server
LOCAL cCC := "" // -> Optional. Character string or array of email adresses for CC (Carbon Copy)
LOCAL cBCC := "" // -> Optional. Character string or array of email adresses for BCC (Blind Carbon Copy)
LOCAL cPOPUser := "" // -> Required. User name for the POP3 server
LOCAL cPOPPassword := "" // -> Required. Password for cUser
LOCAL cPOPServer := "" // -> Required. POP3 server name or address
LOCAL cSMTPUser := "" // -> Required
LOCAL cSMTPPassword:= "" // -> Required
LOCAL nSMTPPort := 587 // -> Optional. Port used my email server
LOCAL nPriority := 3 // -> Optional. Email priority: 1=High, 3=Normal (Standard), 5=Low
LOCAL lRead := .F. // -> Optional. If set to .T., a confirmation request is send. Standard setting is .F.
LOCAL bTrace := .F. // -> Optional. If set to .T., a log file is created (smtp-<nNr>.log). Standard setting is NIL.
LOCAL lPopAuth := .F. // -> Optional. Do POP3 authentication before sending mail.
LOCAL lNoAuth := .f. // -> Optional. Disable Autentication methods
LOCAL nTimeOut := 500 // -> Optional. Number os ms to wait default 20000 (20s)
LOCAL cReplyTo := "" // -> Optional.
LOCAL lTLS := .F. // -> Do not adjust because of the crashes
LOCAL cCharset := "windows-1250"
LOCAL cEncoding := ""
LOCAL LRET

IF !FILE ( cIniFile )
VRAAG ( "Ini file missing" )
RETURN .F.
ENDIF

BEGIN INI FILE cIniFile
GET cFrom SECTION "SETTINGS" ENTRY "FROM" DEFAULT ""
GET cSubject SECTION "SETTINGS" ENTRY "SUBJECT" DEFAULT ""
cSubject := cSubject + " " + ALLTRIM ( DEC ( CUR->A ) )
GET cTo SECTION "SETTINGS" ENTRY "TO" DEFAULT ""
GET cCC SECTION "SETTINGS" ENTRY "CC" DEFAULT ""
GET cBCC SECTION "SETTINGS" ENTRY "BCC" DEFAULT ""
GET cBody SECTION "SETTINGS" ENTRY "BODY" DEFAULT ""
IF ".html" $ cBODY
cBODY := MEMOREAD ( cBODY )
ENDIF
cBody := CHR ( 13 ) + CHR ( 10 ) + STRTRAN ( cBody, CHR ( 141 ), CHR ( 13 ) + CHR ( 10 ) )
cBody := cBody + " ( " + DTOC ( DATE () ) + " " + TIME () + " )"

GET cPOPServer SECTION "SETTINGS" ENTRY "POPServer" DEFAULT ""
GET cPOPUser SECTION "SETTINGS" ENTRY "POPUser" DEFAULT ""
GET cPOPPassword SECTION "SETTINGS" ENTRY "POPPassword" DEFAULT ""
GET cSMTPServer SECTION "SETTINGS" ENTRY "SMTPServer" DEFAULT ""
GET cSMTPUser SECTION "SETTINGS" ENTRY "SMTPUser" DEFAULT ""
GET cSMTPPassword SECTION "SETTINGS" ENTRY "SMTPPassword" DEFAULT ""
GET nSMTPPort SECTION "SETTINGS" ENTRY "SMTPPort" DEFAULT ""
END INI
IF TO <> NIL
cTo := TO
ENDIF
LRET := hb_SendMail( cSMTPServer, nSMTPPort, cFrom, cTo, cCC, cBCC, cBody, cSubject, aAttachments, cPOPUser, cPOPPassword, cPOPServer,;
nPriority, lRead, bTrace, lPopAuth, lNoAuth, nTimeOut, cReplyTo, lTLS, cSMTPPassword, cCharset, cEncoding )
IF ! LRET
VRAAG ( "Error Sending Email, controleer settings..." )
ENDIF
RETURN LRET

I did already try memoread cBODY in case html file
but then source hrml in email showing,
i think charset and/or Encoding must be adjusted ?
Hope you can help me out with this...

And, if it is possible,
can i use this to send with SSL, without installing free-ssl,
want send thru gmail if possible.

Thanks and greetings...

User avatar
danielmaximiliano
Posts: 2359
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 434 times
Been thanked: 84 times
Contact:

Post by danielmaximiliano »

*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

hynan
Posts: 25
Joined: Sat Jun 29, 2013 7:00 pm

Post by hynan »

Hi,

Thanks for your reply,
i wil look in to it...

Greetings.

User avatar
danielmaximiliano
Posts: 2359
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 434 times
Been thanked: 84 times
Contact:

Post by danielmaximiliano »

I made a new version Html to include as part of the email body.
2014-04-08 13_03_31-CDOSYS sending email.jpg
2014-04-08 13_03_31-CDOSYS sending email.jpg (25.54 KiB) Viewed 1562 times
2014-04-08 13_04_44-(7 no leídos) - danielmaximiliano - Yahoo Mail - Aurora.jpg
2014-04-08 13_04_44-(7 no leídos) - danielmaximiliano - Yahoo Mail - Aurora.jpg (66.74 KiB) Viewed 1562 times
CDOsys.rar
Source Files
(116.94 KiB) Downloaded 171 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

Post Reply