B4J Question B4J send HTML email

marcick

Well-Known Member
Licensed User
Longtime User
I feel thet should be simple but I can't find the answer in the forum.

I want to send an email with HTML body, but I know nothing about HTML.
So what I'm, trying to do is :

1) write the email in Outlook.
2) Save the email with "file, Save as HTML"
3) put the file in the object folder
4) load the file as a string in B4j and use it as HTML body.

Of course it does not works .... The email is sent but the body is empty
This is my code:

B4X:
Dim SMTP As SMTP
    SMTP.Initialize("smtps.xxx.it",465,"[email protected]","xxx","smtp")
    SMTP.MailFrom="[email protected]"
    SMTP.HtmlBody=True
    SMTP.Body=File.ReadString(File.DirApp,"senza nome.htm")
    Log(SMTP.Body) ' yes, I see all the HTML body in the log
    SMTP.Subject="test subject"
    SMTP.To.Add ("[email protected]")
    SMTP.UseSSL=True
    SMTP.AuthMethod=SMTP.AUTH_LOGIN
    SMTP.Send
 

DonManfred

Expert
Licensed User
Longtime User
SMTP.HtmlBody=True
are you sure it is a boolean property?
check if the property is a string. PUT the HTML-Code HERE if so.

From the documentation

Property_501.png
SMTP. HtmlBody As Boolean

Gets or sets whether this message body is Html text.

Ok then... Seems not the problem...
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
I think it is not correct to save a whole email from outlook, but I don't know how to do else.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Start with this:
B4X:
SMTP.Body = $"
<b>Hello World!</b>
"$

Does it work?

Yes, it works. I'm trying now to write something with Word, save it as html and load as SMTP.Body but no success again. The email is sent but the body area looks blank.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
I suppose. I just did (into MS Word) a copy&paste of the sign I use in Outlook (that is really simple, a test and a picture).
Then I exported as html and loaded in the SMTP.body
Perhaps I should try with another simple HTML editor, not with Word.
 
Upvote 0
Top