Hello,
I'm using the erel' solution " Building a mini Email based server" to receive a file excel.
if the file attached is XLS, everything is ok.
But if the file attached is XLSX the file is not saved correctly (see image)
maybe the problem is here but I can't find ...
any suggestions?
thank you
I'm using the erel' solution " Building a mini Email based server" to receive a file excel.
if the file attached is XLS, everything is ok.
But if the file attached is XLSX the file is not saved correctly (see image)
maybe the problem is here but I can't find ...
any suggestions?
thank you
B4X:
Sub HandlePart(Headers As String, Body As String, Msg As Message)
If Regex.Matcher2("Content-Transfer-Encoding:\s*base64", _
Regex.CASE_INSENSITIVE, Headers).Find Then
'we are dealing with an attachment
Dim filename As String
Dim m As Matcher
m = Regex.Matcher2("filename=\s*q([^q]+)q".Replace("q", QUOTE), Regex.CASE_INSENSITIVE, Headers)
If m.Find Then filename = m.Group(1) Else filename = "attachment" & (Msg.Attachments.Size + 1)
Dim su As StringUtils
Dim out As OutputStream
out = File.OpenOutput(dir, filename, False)
Dim data() As Byte
data = su.DecodeBase64(Body)
Log("file saved: " & filename & " (" & data.Length & " bytes)")
out.WriteBytes(data, 0, data.Length)
out.Close
Msg.Attachments.Add(filename)
Else If Regex.Matcher2("Content-Type:\s*text/", _
Regex.CASE_INSENSITIVE, Headers).Find Then
Msg.Body = Body
End If
End Sub