I'm looking for a way to send my files to my server via a POST method. But first I would like to convert my files to base64 so that I can send them easily. Only, I can't find any solution on the internet to do that.I'm not even sure it's a good idea to do that.
I tried several methods, including converting directly from the attached files or saving them locally and retrieving them, but nothing works.
Here is my code:
pathname = "C:emp"
Set db = Session.Currentdatabase
Set CurrentDocColl = db.Unprocesseddocuments
Set doc = CurrentDocColl.Getfirstdocument
While Not doc Is Nothing
Set item = doc.GETFIRSTITEM("Body")
If doc.HasEmbedded Then
ForAll attachment In item.EmbeddedObjects
Call attachment.ExtractFile (pathname & "" & attachment.Name)
Set stream = session.Createstream()
stream.Open pathname & "" & attachment.Name, "binary"
'I want retrieve the file in base64 here
data = 'file in base64
Set http=session.CreateHTTPRequest()
http.preferstrings = True
http.Post(url, data)
End ForAll
End If
Set doc=CurrentDocColl.Getnextdocument(doc)
Wend
This code can be found in my agent who is in charge of retrieving the information present in the current email.
Does anyone have any idea how to do this? Or another way to do the same thing?
question from:
https://stackoverflow.com/questions/65938772/lotusscript-convert-files-from-an-email-to-base64-to-send-it-in-post-method 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…