B4J Question Embed an Image in Email

Discussion in 'B4J Questions' started by Reinierus, Jul 21, 2015.

  1. Reinierus

    Reinierus Member Licensed User

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

    Code:
    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 =
    Parte2.txt =
    vrTextoLink = http://www.edintel.com/campanas/bms-energia1.jpg

    The log result is

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

    Any idea?

    Thanks a lot
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Have you set SMTP.HtmlBody to true?
     
  3. Reinierus

    Reinierus Member Licensed User

    Hi Erel.
    Yes, I am using:

    Code:
    vrSMTP.HtmlBody=chkHTML.Checked
        
    Log(vrSMTP.HtmlBody)
    and the result is:

    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:

    What else can be wrong?

    Thanks
     
  4. Reinierus

    Reinierus Member Licensed User

    Hello
    I am trying to put more spaces before and after the "=" symbol or changing the code like this:
    Code:
    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
     
  5. rwblinn

    rwblinn Well-Known Member Licensed User

    Hi,

    looks like a bug in SMTP. Tested as follows:

    1. Created in B4J Body Text with HTMLBody = True
    Code:
    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"
    Code:
    <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
    Code:
    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.
    Code:
    <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>
     
  6. Reinierus

    Reinierus Member Licensed User

    Thank you Rob.
    I trying adding spaces, "h" and "=", but the result is almost the same.
    I believe that the problem is the "=".
    The news are there is a broken link image (see attach).

    Another idea?

    Best regards,
     

    Attached Files:

  7. Reinierus

    Reinierus Member Licensed User

    rwblinn likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice