B4J Question Embed an Image in Email

Reinierus

Member
Licensed User
Longtime User
Hello.
I am trying to embed an image in a email, but it doesn't work.
This is my code:

B4X:
If chkHTML.Checked=True Then
                Dim vrTextoLink As String
                Dim vrParte1 As String
                Dim vrParte2 As String
                vrTextoLink=vrSMTP.Body
                vrParte1=File.ReadString(File.DirAssets,"Parte1.txt")
                vrParte2=File.ReadString(File.DirAssets,"Parte2.txt")
                vrSMTP.Body=vrParte1 & vrTextoLink & vrParte2
                Log(vrSMTP.Body)
            End If

Where
Parte1.txt =
<html>
<body>
<p>
This is a paragraph displayed before the picture.
</p>
<img src="

Parte2.txt =
"
width="250"
height="95"
border="0"
alt="my picture">
<br>
This is a caption for the picture.
<p>
This is a paragraph displayed after the picture.
</p>
</body>
</html>

vrTextoLink = http://www.edintel.com/campanas/bms-energia1.jpg

The log result is

<html>
<body>
<p>
This is a paragraph displayed before the picture.
</p>
<img src="http://www.edintel.com/campanas/bms-energia1.jpg"
width="250"
height="95"
border="0"
alt="my picture">
<br>
This is a caption for the picture.
<p>
This is a paragraph displayed after the picture.
</p>
</body>
</html>

But the image is not displayed in the email client (yes, I pulsed the "Show Remote Content" button)

Any idea?

Thanks a lot
 

Reinierus

Member
Licensed User
Longtime User
Hi Erel.
Yes, I am using:

B4X:
vrSMTP.HtmlBody=chkHTML.Checked
    Log(vrSMTP.HtmlBody)

and the result is:

Program started.
true
<html>
<body>
<p>
This is a paragraph displayed before the picture.
</p>
<img src="http://www.edintel.com/campanas/entec.jpg"
width="250"
height="95"
border="0"
alt="my picture">
<br>
This is a caption for the picture.
<p>
This is a paragraph displayed after the picture.
</p>
</body>
</html>

But the image doesn't appear in the email client.

By the way, in the email client, the message source (I don't how to say it in English) shows this:

<html>
<body>
<p>
This is a paragraph displayed before the picture.
</p>
<img src ttp://www.edintel.com/campanas/entec.jpg"
width50"
height 5"
border "
alt y picture">
<br>
This is a caption for the picture.
<p>
This is a paragraph displayed after the picture.
</p>

What else can be wrong?

Thanks
 
Upvote 0

Reinierus

Member
Licensed User
Longtime User
Hello
I am trying to put more spaces before and after the "=" symbol or changing the code like this:
B4X:
vrSMTP.Body=vrParte1 & Chr(61) & Chr(34) & vrTextoLink & vrParte2
But doesn't work either.
It looks like the "=" is not valid in the .body
It is a bug or I am doing something wrong?

Thanks a lot
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

looks like a bug in SMTP. Tested as follows:

1. Created in B4J Body Text with HTMLBody = True
B4X:
taBody.Text = "<html><body><p>This Is a paragraph displayed before the picture.</p>" & _
                  "<img src='http://www.rwblinn.de/metroblog.png'></img>" & _
                  "<br>This Is a caption For the picture.<p>This Is a paragraph displayed after the picture.</p></body></html>"

2. Send to my email address and opened in Outlook. Saved the email as HTML.
In the HTML file, in the link to the IMG file, the h from http is missing.
src="ttp://www.rwblinn.de/metroblog.png"
B4X:
<p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'><img
id="_x0000_i1025" src="ttp://www.rwblinn.de/metroblog.png"><br>
</img>This Is a caption For the picture.<o:p></o:p></span></p>

3. Created new body but with extra h for the IMG link
B4X:
taBody.Text = "<html><body><p>This Is a paragraph displayed before the picture.</p>" & _
                  "<img src='hhttp://www.rwblinn.de/metroblog.png'></img>" & _
                  "<br>This Is a caption For the picture.<p>This Is a paragraph displayed after the picture.</p></body></html>"

4. Send to my email address and opened in Outlook. Saved the email as HTML.
The link to the IMG is correct and the image is displayed.
B4X:
<p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'><img
id="_x0000_i1025" src="http://www.rwblinn.de/metroblog.png"><br>
</img>This Is a caption For the picture.<o:p></o:p></span></p>
 
Upvote 0

Reinierus

Member
Licensed User
Longtime User
Thank you Rob.
I trying adding spaces, "h" and "=", but the result is almost the same.
<html><body><p>This Is a paragraph displayed before the picture.</p>
<img src http://www.edintel.com/campanas/entec.jpg'></img=
>
<br>This Is a caption For the picture.<p>This Is a paragraph displ=
ayed after the picture.</p>

I believe that the problem is the "=".
The news are there is a broken link image (see attach).

Another idea?

Best regards,
 

Attachments

  • Email result.png
    Email result.png
    16.8 KB · Views: 192
Upvote 0
Top