Page 1 of 1

How to Send HTML Mail with GMAIL?

Posted: Tue May 10, 2016 7:53 am
by Liqu
Hi, i want to send HTML mail with Zurb Foundation : http://foundation.zurb.com/emails.html

but i can't send it, the html code sent as plain text.

I'm trying to send HTML Mail with Attachments.

Using this code can send plain text just fine.

Code: Select all

; process to test new email capabilities in PB 5.40

EnableExplicit

;****************************************************************************************
; send out the page to the secure server
;****************************************************************************************

Procedure SendPage()

    Protected result.i
    Protected logText.s
    Protected mailNumber.i
    Protected emailType.s    = "text/plain"
    Protected mailHost.s     = "smtp.gmail.com"
    Protected userName.s     = "testtest@gmail.com"
    Protected mailFrom.s     = "testtest@gmail.com"
    Protected mailPort.i     = 587
    Protected mailTo.s       = "testtest@yahoo.co.id"
    Protected subject.s      = "64 bit email Test using TLS Encryption"
    Protected emailBody.s    = "Dear Sir, this email is brought to you courtesy of 64 bit TLS Encryption."
    
    password.s = "testtest"
    
;     PrintN("Enter the password for " + userName)
;     Protected password.s     = Input()

    PrintN("SendPage() > About to create mail!")

    mailNumber = CreateMail(#PB_Any, userName, subject)
    If mailNumber > 0
        AddMailRecipient(mailNumber, mailTo, #PB_Mail_To)
        SetMailBody(mailNumber, emailBody)
        result = AddMailAttachmentData(mailNumber, "attachment", @emailBody, Len(emailBody), emailBody)
        PrintN("SendPage() > AddMailAttachmentData return value: " + Str(result))
        result = SendMail(mailNumber, mailHost, mailPort, #PB_Mail_UseSSL, userName, password)
        PrintN("SendPage() > SendMail return value: " + Str(result))
        FreeMail(mailNumber)
    Else
        PrintN("SendPage() > error creating mail process")
    EndIf

EndProcedure

; open the console window, initialize the network, send the message, then quit

InitNetwork()

OpenConsole()

SendPage()

Input()

CloseConsole()
; IDE Options = PureBasic 5.42 LTS (Windows - x86)
; CursorPosition = 34
; FirstLine = 4
; Folding = -
; EnableXP