Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
608 views
in Technique[技术] by (71.8m points)

lotus notes - Lotusscript: Convert files from an email to base64 to send it in POST method

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can find some useful functions for working with base64 data in LotusScript on Julian Robicaux's old NSFTools website: https://www.nsftools.com/tips/Base64v14.lss


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...