fchirico
Member
Hello, According to the post https://www.b4x.com/android/forum/threads/class-send-e-mail-with-fileprovideruri.89217/
I would like to send the email in HTML format.
I modified where it says EmailIntent.SetType ("text / plain") by EmailIntent.SetType ("text / html").
But it is not interpreting the HTML code, it sends the email literally, that is, the html code appears in the body of the email.
What am I doing wrong?
This is the HTML code:
I would like to send the email in HTML format.
I modified where it says EmailIntent.SetType ("text / plain") by EmailIntent.SetType ("text / html").
But it is not interpreting the HTML code, it sends the email literally, that is, the html code appears in the body of the email.
What am I doing wrong?
This is the HTML code:
B4X:
Sub EnviarCorreoDeConfirmacion
Dim cEncab As String
Dim cBody = " " As String
Dim cBody2 = " " As String
Dim i As Int
cEncab = $"
<!DOCTYPE html Public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Arimex Importadora S.A.</title>
</head>
<body>
<h1>Su pedido: ${cNumPed} Sucursal: ${Main.cSucursal} </h1>
<h1>Fecha: ${Main.cFecha} </h1>
<h1>Cliente: ${lbl_NomCli.text} - ${lbl_CodCli.text}/${lbl_LojaCli.text} </h1>
<h1>Vendedor: ${lbl_CodVen.text} - Usuario GA.MA Tools: ${Main.cUSR_usuario} </h1>
<h1>Canal: ${cCanal} Condición de Pago: ${edt_CondPa.text} Dto.Global: ${lbl_DtoG01.text}</h1>
<h1>Dirección de Entrega: ${edt_DirEntre.text} </h1>
<h1>Mensaje para Factura: ${edt_MensajeFac.text} </h1>
<table>
<tr>
<th scope="col">Producto</th>
<th scope="col">Nombre producto</th>
<th scope="col">Precio unitario</th>
<th scope="col">Unidades</th>
<th scope="col">Dto.de Linea</th>
</tr>"$
For i = 0 To nIndiceLineaPedido - 1
If User4(i).LinPed_Cantidad > 0 Then
cBody = cBody & $"<tr>
<td>${User4(i).LinPed_CodProd}</td>
<td>${User4(i).LinPed_DescriPro}</td>
<td>${User4(i).LinPed_Precio}</td>
<td>${User4(i).LinPed_Cantidad}</td>
<td>${User4(i).LinPed_DtoLin} </td>
</tr>"$
End If
Next
cEncab = cEncab & cBody & $"</table> </body> </html>"$
Main.sendmail.Send(Main.cUSR_email,File.DirInternal, cEncab, "GA.MA Tools - Pedido generado: " & cNumPed & " (" & Main.cEntorno & ")", "")
End Sub
B4X:
Private Sub SendEmail (SendTo As String, SendBody As String, SendSub As String, SendAtt As String)
Dim EmailIntent As Intent
LogColor("Send Att: " & SendAtt, Colors.Red)
EmailIntent.Initialize(EmailIntent.ACTION_SEND, SendTo)
EmailIntent.putExtra("android.intent.extra.SUBJECT", SendSub)
EmailIntent.putExtra("android.intent.extra.TEXT", SendBody)
'EmailIntent.SetType("text/plain") 'it is not related to the file itself.
EmailIntent.SetType("text/html") 'it is not related to the file itself.
EmailIntent.Flags = 1
If SendAtt <> "" Then
EmailIntent.PutExtra("android.intent.extra.STREAM", CreateFileProviderUri(shared, GlobFileName))
End If
StartActivity (EmailIntent)
End Sub
Last edited: